| | #!/bin/sh |
---|
| | # promptuser.sh - User Prompting From Shell With validation |
---|
| | # Copyright (c) 2010, TundraWare Inc, Des Plaines, IL USA |
---|
| | # All Rights Reserved |
---|
| | # $Id: tpromptuser.sh,v 1.103 2010/10/07 18:58:50 tundra Exp $ |
---|
| | # $Id: tpromptuser.sh,v 1.104 2010/10/07 19:12:17 tundra Exp $ |
---|
| | |
---|
| | # Loop through a set of questions for the user to answer, storing |
---|
| | # their response back into the prompt variable itself. |
---|
| | # |
---|
| |
---|
| | baz="Would you like to baz?${DL}n${DL}${YN} yup" |
---|
| | bat="Would you like to bat?${DL}${DL}nope" |
---|
| | |
---|
| | |
---|
| | PROMPTLIST="foo bar baz bat" |
---|
| | |
---|
| | # Display the records for purposes of this example only |
---|
| | |
---|
| | echo "Before: foo->$foo bar->$bar baz->$baz bat->$bat" |
---|
| | |
---|
| |
---|
| | # Actual Prompting Logic |
---|
| | ##### |
---|
| | |
---|
| | |
---|
| | for x in "foo" "bar" "baz" "bat" |
---|
| | for x in $PROMPTLIST |
---|
| | do |
---|
| | eval record=\$$x # Get the prompt record |
---|
| | IFS=$DL # Get individual fields |
---|
| | read prompt default answers <<EOF |
---|
| |
---|
| | |