aquaballoon

sh - while; menu

Dec 5th, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.90 KB | None | 0 0
  1. while :
  2. do
  3.     clear
  4.         # display menu
  5.         echo "Server Name - $(hostname)"
  6.     echo "-------------------------------"
  7.     echo "     M A I N - M E N U"
  8.     echo "-------------------------------"
  9.     echo "1. Display date and time."
  10.     echo "2. Display what users are doing."
  11.     echo "3. Display network connections."
  12.     echo "4. Exit"
  13.         # get input from the user
  14.     read -p "Enter your choice [ 1 -4 ] " choice
  15.         # make decision using case..in..esac
  16.     case $choice in
  17.         1)
  18.             echo "Today is $(date)"
  19.             read -p "Press [Enter] key to continue..." readEnterKey
  20.             ;;
  21.         2)
  22.             w  
  23.             read -p "Press [Enter] key to continue..." readEnterKey
  24.             ;;
  25.         3)
  26.             netstat -nat
  27.             read -p "Press [Enter] key to continue..." readEnterKey
  28.             ;;
  29.         4)
  30.             echo "Bye!"
  31.             exit 0
  32.             ;;
  33.         *)
  34.             echo "Error: Invalid option..."
  35.             read -p "Press [Enter] key to continue..." readEnterKey
  36.             ;;
  37.     esac       
  38.  
  39. done
  40.  
Advertisement
Add Comment
Please, Sign In to add comment