Gogeden
April 2nd, 2012, 06:23 PM
I'm having two strange bugs with my program I wrote in Bash. I'll start the program, call another script, then return to the first script and for some weird reason the first script will display the correct text but have the corresponding options (If I press 1 it'll do what ever 1 corresponds with in the previous script) of the previous script I launched. That's the first bug. The second is that I get this error when trying to launch script 2:
./misc/clean.sh: line 31: syntax error: unexpected end of file
I'm still learning Bash and I've been stumped on this problem for weeks. Here's the two scripts:
Script 1:
#!/bin/bash
clear
echo "GISAH on"; uname -o
# =============================================
function clean_hdd {
./misc/clean.sh;
}
function self-clean {
./misc/self_clean.sh;
}
function exit {
break;
}
select choice in \
"Clean Hard-disk" \
"Self-Cleaning" \
"Power Menu" \
"Exit"
do
case $choice in
"Clean Hard-disk")
clean_hdd;
;;
"Self-Cleaning")
self-clean;
;;
"Power Menu")
main_menu;
;;
"Exit")
break;
exit
;;
*)
echo "Please select an option";
;;
esac
done
================================================== ======
Script 2:
================================================== ======
#! /bin/bash
clear
function firefox {
echo "firefox";
}
function main {
select choice in \
"Firefox" \
"Main Menu"
do
case $choice in
"Firefox")
rm -r ~/.mozilla/firefox/*.default/Cache/;
cd ~/.mozilla/firefox/*.default/;
mkdir ./Cache;
;;
"Main Menu")
cd ~/Desktop/GISAH_BASH/;
./GISAH.sh
;;
esac
done
Here's how to reproduce the bug, save and name that first script "GISAH.sh" (Name of my program) and then chmod +x it, then launch it. Press 1 to call the second script. You'll get that second error I mentioned. If anyone can fix that let me know I'd appreciate it. I had it fixed once but then I screwed something up while diagnosing the first problem I mentioned. Then, when that script gets launched, go back to the previous menu by pressing 2.
Really need the help. Thanks! :D
./misc/clean.sh: line 31: syntax error: unexpected end of file
I'm still learning Bash and I've been stumped on this problem for weeks. Here's the two scripts:
Script 1:
#!/bin/bash
clear
echo "GISAH on"; uname -o
# =============================================
function clean_hdd {
./misc/clean.sh;
}
function self-clean {
./misc/self_clean.sh;
}
function exit {
break;
}
select choice in \
"Clean Hard-disk" \
"Self-Cleaning" \
"Power Menu" \
"Exit"
do
case $choice in
"Clean Hard-disk")
clean_hdd;
;;
"Self-Cleaning")
self-clean;
;;
"Power Menu")
main_menu;
;;
"Exit")
break;
exit
;;
*)
echo "Please select an option";
;;
esac
done
================================================== ======
Script 2:
================================================== ======
#! /bin/bash
clear
function firefox {
echo "firefox";
}
function main {
select choice in \
"Firefox" \
"Main Menu"
do
case $choice in
"Firefox")
rm -r ~/.mozilla/firefox/*.default/Cache/;
cd ~/.mozilla/firefox/*.default/;
mkdir ./Cache;
;;
"Main Menu")
cd ~/Desktop/GISAH_BASH/;
./GISAH.sh
;;
esac
done
Here's how to reproduce the bug, save and name that first script "GISAH.sh" (Name of my program) and then chmod +x it, then launch it. Press 1 to call the second script. You'll get that second error I mentioned. If anyone can fix that let me know I'd appreciate it. I had it fixed once but then I screwed something up while diagnosing the first problem I mentioned. Then, when that script gets launched, go back to the previous menu by pressing 2.
Really need the help. Thanks! :D