Another way to write bash menu script


/ Published in: Bash

Another way of writing a continuous bash menu.


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.