Make Backup (y/n)? [y] This (Web server application) lets the user
Make Backup (y/n)? [y] This lets the user simply press Enter and have the backup made. It also lets the user type a response. Prompting for a Response In many shell scripts, you need to gather more information from the user than a yes or no response. For example, installation scripts frequently have to ask for the name of a directory, the location of a file, or other system information. The promptYESNO function cannot handle these types of questions. You need a different kind of prompting function, which you present as the promptRESPONSE function. This function displays a prompt, reads the user’s response, and stores it in the variable RESPONSE. Validation of the user’s response needs to be handled outside of the function. ################################################ # Name: promptRESPONSE # Desc: ask a question # Args: $1 -> The prompt # $2 -> The default answer (optional) # Vars: RESPONSE -> set to the users response ################################################ promptRESPONSE() { if [ $# -lt 1 ] ; then printERROR “Insufficient Arguments.” return 1 fi RESPONSE=”" DEF_ARG=”$2″ while : do printf “$1 ? ” if [ -n “$DEF_ARG” ] ; then printf “[$DEF_ARG] ” fi read RESPONSE if [ -n “$RESPONSE” ] ; then break elif [ -z “$RESPONSE” -a -n “$DEF_ARG” ] ; then RESPONSE=”$DEF_ARG” break fi done export RESPONSE unset DEF_ARG return 0
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.