Require input in bash dialog box

Programming languages, Coding, executables, and scripting.
Post Reply
Posts: 3
Joined: 2012-11-27 19:50

Require input in bash dialog box

#1 Post by woodson2 »


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

rfcval=`cat $rfcfile`

case $retval in
    echo RFC Number: "$rfcval" >> $accessfile;;
    exit 1;;
    rm -rf $accessfile && rm -rf $tempfile && rm -rf $rfcfile && rm -rf $sitefile && exit 1;;

User avatar
Posts: 7775
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Require input in bash dialog box

#2 Post by dasein »

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?

User avatar
Posts: 3064
Joined: 2013-03-12 07:18

Re: Require input in bash dialog box

#3 Post by debiman »

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?

User avatar
Posts: 1704
Joined: 2010-03-09 09:38
Location: The Matrix

Re: Require input in bash dialog box

#4 Post by phenest »

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

Post Reply