Require input in bash dialog box

Code junkies hangout here

Moderators: ChriThor, LXF moderators

Require input in bash dialog box

Postby woodson2 » Sat Mar 18, 2017 3:29 pm

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

woodson2
 
Posts: 1
Joined: Tue Nov 27, 2012 8:24 pm

Re: Require input in bash dialog box

Postby nelz » Sun Mar 19, 2017 7:18 pm

Code: Select all
if [ $(wc -c <$rcfile ) -lt 5 ]; then
    Not enough characters entered
fi
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 9008
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron