Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
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
Old May 19th, 2005, 3:46 PM   #2
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
That is /bizarre/. Sorry, I have no idea. But at least I've incremented my post count.

Whew. I'm still boggling at it, but I can't see a problem. Sorry. The closest thing I have to a suggestion is something to do with the backticks or a line terminator but I really can't see how either of those is at fault - the line with the backticks is obviously working with the echo commented out, and the backticks will not have left a line terminator on your variable, whic shouldn't cause problems even if they did.

It really boggles the mind. All I can suggest is taking the quotes off the echo "$choice" line; it doesn't make sense, but when all else fails, rephrase the code pointlessly.
mackenga is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC