Results 1 to 3 of 3
hi, Im trying to check for empty boxes with dialog and bash, and it seems to error even if there is input. I don't know if these are the correct ...
- 07-16-2007 #1Just Joined!
- Join Date
- Nov 2006
- Posts
- 90
making error checks in bash
hi, Im trying to check for empty boxes with dialog and bash, and it seems to error even if there is input. I don't know if these are the correct params or if im just missing something. this is a small section (the section i cant figure out) of a much larger script so bear with me please
backtrack is to go to the beginning of the script. it just calls the main script and terminates. (i dont know how to do that internally either)Code:elif [ $R = "8" ]; then dialog --no-shadow \ --backtitle "Bugspray V1.7 Alpha Experimental" \ --title "Where?" \ --inputbox "where is the file? (eg. sda1, etc)" 8 40 \ 2>/tmp/dialog1.ans if [ $? = 1 ]; then dialog --no-shadow \ --backtitle "Bugspray V1.7 Alpha Experimental" \ --title "oops!" \ --msgbox "You need to specify a location" 25 78 #/run/backtrack #real command /home/kainalu/Desktop/backtrack #for now exit 0 else dialog --no-shadow \ --backtitle "Bugspray V1.7 Alpha Experimental" \ --title "Name?" \ --inputbox "What is the name?" 8 40 \ 2>/tmp/dialog2.ans fi if [ $? = 1 ]; then dialog --no-shadow \ --backtitle "Bugspray V1.7 Alpha Experimental" \ --title "oops!" \ --msgbox "You need to specify a name" 25 78 #/run/backtrack #real command /home/kainalu/Desktop/backtrack #for now exit 0 else what="`cat /tmp/dialog2.ans`" where="`cat /tmp/dialog1.ans`" #find /mnt/$where -iname "$what" -exec rm -rvf {} \; >> /tmp/dialog3.ans #real command find $where -iname "$what" -exec rm -rvf {} \; >> /tmp/dialog3.ans dialog --no-shadow \ --backtitle "Bugspray V1.7 Alpha Experimental" \ --title "Done!" \ --textbox /tmp/dialog3.ans 25 78 rm -f /tmp/dialog1.ans rm -f /tmp/dialog2.ans rm -f /tmp/dialog3.ans fi
- 07-16-2007 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Two quick things that stand out -
You have started in the middle of an if test (elif).
You can call the script easily from within itself. A script can reference itself using the $0 variable. I'll try to have a better look tomorrow, just going offline now.
- 07-16-2007 #3Just Joined!
- Join Date
- Nov 2006
- Posts
- 90
yes, its a 17k script, this is just the "broke part" thanks for the tip on the $0!!
also how do you tell a script to hold off executing anything else for awhile? i have this part later in the script that is supposed to show Midnight Commander but it just blinks the screen and hoes back to the main menu
elif [ $R = "19" ]; then # display Midnight Commander
clear
mc
i need the script to hold off until mc exits.
nevermind, found THIS mistake
elif [ $R = "19" ]; then
should be:
elif [ $R = "18" ]; then
stoopit mistake. still need help with the first post though


Reply With Quote