Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Basically I am writing a script that will run other scripts.
I want to add an if statement, and I don't know what the best way about that would be. The main script has 5 cases, each case runs 3 different scripts and the last one is simply a quit. Inside each case though I want to add an IF statement that will verify that the user wants to run the scripts, and if the user chooses 'y' or 'Y' then it continues to run the scripts inside that case, and if the user chooses 'n' or 'N' then it quits the script or just returns to the main menu part.
Here is what I have so far, and I'm pretty new to scripting and I can't figure out the best way to incorporate the if statement.
select x in a1 a2 a3 a4 Quit
do
case $x in
a1)...path.../script1.sh
...path.../script2.sh
...path.../script3.sh
break;;
a2)...path.../script4.sh
...path.../script5.sh
...path.../script6.sh
break;;
a3)...path.../script7.sh
...path.../script8.sh
...path.../script9.sh
break;;
a4)...path.../script10.sh
...path.../script11.sh
...path.../script12.sh
break;;
*)break;;
esac
done
Thanks for your help.
Oh, and all the scripts being called inside the case statements, simply run a command.
Not homework. I'm attempting to write a script that will shutdown/stop WebLogic instances. As it is right now we have many instances on many different servers and I am trying to make a weekly process go faster for me. The script will only allow you to choose which combo of instances you want to start up, and then it will auto run the scripts that start them.
a-b)
echo -en "You chose to start a and b, is this correct? "
response="n"
read response
if ["${response}" = y -a "${response}" = Y ]; then
/PATH/startservera.sh
/PATH/startserverb.sh
/PATH/startservere.sh
fi
That is what I currently have in my first case that I want to have in each one. I obviously changed names and stuff though. Basically I have four cases that can start any combo of server abcd where only A or B can be started at one time, and only C or D can be started, and server e starts regardless of which option is chosen.
EDIT:
This is the error I keep getting
./test2.sh: line 11: [y: command not found
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.