Require input in bash dialog box

Need help with C, C++, perl, python, etc?

Require input in bash dialog box

Postby woodson2 » 2017-03-18 14:30


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;;

Posts: 3
Joined: 2012-11-27 19:50

Re: Require input in bash dialog box

Postby dasein » 2017-03-18 16:11

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: 7208
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Require input in bash dialog box

Postby debiman » 2017-03-18 18:21

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: 712
Joined: 2013-03-12 07:18

Re: Require input in bash dialog box

Postby phenest » 2017-03-18 18:40

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.
Dell XPS 17 L702X i7 2860QM 2.5GHz - 32GB RAM - 4G WWAN - Pioneer TD05-BDR
NEC Spirit 550 Pentium 4 3.6GHz HT - 2GB RAM - nVidia 7600GT - Promise TX4310 RAID + 4 SSD's - Pioneer BDR-209DBK
ASUS P8P67 EVO i7 3770K - 32GB RAM - 2x nVidia 660GTX SLI'd
User avatar
Posts: 1045
Joined: 2010-03-09 09:38
Location: The Matrix

Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests