0

Hello,

I've created a simple menu that will execute some commands, and display them on the screen. However, when I try to execute them in the menu, nothing appears. I was not sure if I went about this the right way. Any help is appreciated.

trap "rm ./f 2> /dev/null; exit" 0 1 3
projectfile=!/project1
loop=y
while test $loop = "y"
do
 clear
 tput cup 1 12: echo "Welcome " logname;
 tput cup 3 12; echo "Project 1 Sample Menu"
 tput cup 4 12; echo "====================="
 tput cup 6 9; echo "P - Display List Of Current Users"
 tput cup 7 9; echo "C - Display The Current Month's Calender"
 tput cup 8 9; echo "L - Display The Last 20 Users In The Password File"
 tput cup 10 9; echo "Q - Exit: "
 tput cup 12 19;
 read choice || continue
   case $choice in
     [Pp]) echo users ;;
     [Cc]) echo  cal -y ;;
     [Ll]) echo sed -n '1409,1428p' /etc/passwd ;;
     [Qq]) clear ; exit ;;
     *)tput cup 14 4; echo "Invalid Code"; read choice ;;
 esac
done

Edited by BTW8892: n/a

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by JeoSaurus
0

Hi BTW8892!

Your script actually IS working! It's just that you're clearing the results immediately after :)

After you accept input and execute the corresponding command, it loops back to the beginning, which starts with "clear" on line 6.

Also, I'm not sure if this is intentional, but your actions in that case statement are all preceded by the 'echo' command, which means that all that will be printed to the screen is the actual command, not the results that you'd expect.

-> echo users
Output: "users"

-> echo cal -y
Output: "cal -y"

-> echo sed -n '1409,1428p' /etc/passwd
Output: "sed -n '1409,1428p' /etc/passwd"

If that's what you intended, then ignore me :) Otherwise, just take out the 'echo' and it will execute the commands and display the output (until it's cleared when looping back to the menu, of course)

I hope this helps!
-G

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.