![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: May 2005
Posts: 1
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4
![]() |
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. ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|