Thursday, December 11, 2014

Menu Driven Program in Bash Shell Script

Menu Driven Program in Bash Shell Script
===============================
while :
do
clear
echo " M A I N - M E N U"
echo "1. Contents of /etc/passwd"
echo "2. List of users currently logged"
echo "3. Present handling directory"
echo "4. Exit"

echo -n "Please enter option [1 - 4]"

read opt

case $opt in

1) echo "************ Conents of /etc/passwd *************";

more /etc/passwd;;

2) echo "*********** List of users currently logged";

who |less;;

3) echo "You are in $(pwd) directory";

echo "Press [enter] key to continue. . .";

read enterKey;;

4) echo "Bye $USER";

exit 1;;

*) echo "$opt is an invaild option. Please select option between 1-4 only";

echo "Press [enter] key to continue. . .";

read enterKey;;

esac

done
=======================================================
Output:
 M A I N - M E N U
1. Contents of /etc/passwd
2. List of users currently logged
3. Prsent handling directory
4. Exit
Please enter option [1 - 4]

No comments:

Post a Comment

TCP/UDP Protocols/Prots & important port numbers in Linux OS

TCP/UDP Protocols/Ports are ranging from 0-65535 so total we have 65536 ports & because of the limitation in TCP/IP stack where the por...