Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Require input in bash dialog box

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
woodson2
Posts: 3
Joined: 2012-11-27 19:50

Require input in bash dialog box

#1 Post by woodson2 »

Hello.

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=${DIALOG=dialog}
$DIALOG --title "RFC NUMBER" --clear \
        --inputbox "Please enter an RFC Number" 16 17 2> $rfcfile

retval=$?
rfcval=`cat $rfcfile`

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


User avatar
dasein
Posts: 7680
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
debiman
Posts: 3063
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
phenest
Posts: 1702
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