Posted By

jaduks on 12/21/08


Tagged

menu Shell Bash script cat


Versions (?)

Who likes this?

9 people have marked this snippet as a favorite

ascarion
sulfurito
xuanyan
romulousprime
vkolev
jeremydouglass
vthreex
szpunk
naesk


Another way to write bash menu script


 / Published in: Bash
 

URL: http://unstableme.blogspot.com/2008/06/bash-script-menu.html

Another way of writing a continuous bash menu.

  1. #!/bin/sh
  2.  
  3. f_Reg () {
  4. echo "Regression function"
  5. echo "All your logic in this function"
  6. }
  7.  
  8. f_Smoke () {
  9. echo "Smoke function"
  10. echo "All your logic in this function"
  11. }
  12.  
  13. while : # Loop forever
  14. do
  15. cat << !
  16.  
  17. R U N M E N U
  18.  
  19. 1. Regression Tests
  20. 2. Smoke Tests
  21. 3. Quit
  22.  
  23. !
  24.  
  25. echo -n " Your choice? : "
  26. read choice
  27.  
  28. case $choice in
  29. 1) f_Reg ;;
  30. 2) f_Smoke ;;
  31. 3) exit ;;
  32. *) echo "\"$choice\" is not valid "; sleep 2 ;;
  33. esac
  34. done

Report this snippet  

You need to login to post a comment.