View Single Post
Old May 10th, 2005, 6:07 PM   #1
Rezin8r
Newbie
 
Join Date: May 2005
Posts: 1
Rep Power: 0 Rezin8r is on a distinguished road
dialog wierdness

hello,

I just started bash scripting a couple of weeks ago, so i am rather noobish. I have previously written a backup script to do batch backups of various types of firewalls. After discovering 'dialog' i decided to make an interactive mode available for single backups. I have been having some issue with returning dialog menu input to the calling function. Here is the code:

function main_menu {
dialog --clear --backtitle "Firewall Backup and Restore" \
--title "Main menu" \
--menu "Select Action" 10 25 6 \
1 "Backup" \
2 "Restore" 2> .tempfile
choice=`cat .tempfile`
rm -f .tempfile
#echo "$choice"
return $choice
}

for some reason, this will not return anything and just exits unexpectedly. Here is the wierd part, if i uncomment that '#echo "$choice"' line, then it will magically work! WTF?! Is there some kind of buffer or something i need to clear before passing the variable? or am i just being a noob?

EDIT
i forgot to mention that if i dont delete the .tempfile in the script, and manually inspect it after the program quits, i see the expected results of the menu input. ARGH!

Last edited by Rezin8r; May 10th, 2005 at 6:14 PM.
Rezin8r is offline   Reply With Quote