Skip to content

Instantly share code, notes, and snippets.

@seangeleno
Last active August 21, 2017 02:28
Show Gist options
  • Save seangeleno/2ffa4167ff0988f9cd3253953da24a47 to your computer and use it in GitHub Desktop.
Save seangeleno/2ffa4167ff0988f9cd3253953da24a47 to your computer and use it in GitHub Desktop.
Prompt User
# (1) prompt user, and read command line argument
read -p "Run the cron script now? " answer
# (2) handle the command line argument we were given
while true
do
case $answer in
[yY]* ) /usr/bin/wget -O - -q -t 1 http://www.example.com/cron.php
echo "Okay, just ran the cron script."
break;;
[nN]* ) exit;;
* ) echo "Dude, just enter Y or N, please."; break ;;
esac
done
@seangeleno
Copy link
Author

second version stays in a loop until the user supplies a Y/N answer:

while true
do
  # (1) prompt user, and read command line argument
  read -p "Run the cron script now? " answer

  # (2) handle the input we were given
  case $answer in
   [yY]* ) /usr/bin/wget -O - -q -t 1 http://www.example.com/cron.php
           echo "Okay, just ran the cron script."
           break;;

   [nN]* ) exit;;

   * )     echo "Dude, just enter Y or N, please.";;
  esac
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment