Programming languages, Coding, executables, and scripting.
- Posts: 3
- Joined: 2012-11-27 19:50
Any help would be greatly appreciated.
Right now I have the following input box that works fine and well, however I would like to wrap this is a loop that requires input. Right now the script will happily continue on if the user just hits enter. I'd like to require a minimum of a 5 digit number or n/a or N/A as the only viable options otherwise you should get prompted to re-enter information.
Code: Select all
$DIALOG --title "RFC NUMBER" --clear \
--inputbox "Please enter an RFC Number" 16 17 2> $rfcfile
case $retval in
echo RFC Number: "$rfcval" >> $accessfile;;
rm -rf $accessfile && rm -rf $tempfile && rm -rf $rfcfile && rm -rf $sitefile && exit 1;;
- Posts: 7775
- Joined: 2011-03-04 01:06
- Location: Terra Incantationum
Maybe I'm missing something, but it sounds like you already have your solution. You know that you need to use a loop, and you know the condition(s) that should cause your loop to end.
If you're imagining that you're still missing "a piece," the only thing I can think of is the (optional) use of a "flag" variable to signal success/failure. What else do you imagine that you'd need?
- Posts: 3064
- Joined: 2013-03-12 07:18
can't dialog be told to not accept empty input, i.e. to force the user to input an actual string and not just enter?
- Posts: 1704
- Joined: 2010-03-09 09:38
- Location: The Matrix
Maybe it would be better if you check the input to see if it's a 5 digit number, and if not, break with an error, and don't use a loop.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D