Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 14th, 2012  |  syntax: None  |  size: 0.82 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. # Interactive wizard to walk the user through a process.
  4. # Tracks steps completed; allows user to exit at any point and pick back up there.
  5.  
  6. function step1 () {
  7.     read -p "step 1 ok, $1? " ok
  8. }
  9.  
  10. function step2 () {
  11.     read -p "step 2 ok, $1? " ok
  12. }
  13.  
  14. function step3 () {
  15.     read -p "step 3 ok, $1? " ok
  16. }
  17.  
  18. function step4 () {
  19.     read -p "step 4 ok, $1? " ok
  20. }
  21.  
  22. function step5 () {
  23.     read -p "step 5 ok, $1? " ok
  24. }
  25.  
  26. function step6 () {
  27.     read -p "step 6 ok, $1? " ok
  28. }
  29.  
  30. function step7 () {
  31.     read -p "step 7 ok, $1? " ok
  32. }
  33.  
  34. base=${0%.sh}
  35. if [ ! -e $base.cfg ] ; then
  36.     # initialize the file with all the steps
  37.     echo -e "step1\nstep2\nstep3\nstep4\nstep5\nstep6\nstep7" > $base.cfg
  38. fi
  39.  
  40. for x in `grep -v ^# $base.cfg` ; do
  41.     $x foo
  42.     # mark the step complete with a hash.
  43.     sed -i "s/$x/# $x/;" $base.cfg
  44. done