LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Executing a script from within a script (https://www.linuxquestions.org/questions/linux-newbie-8/executing-a-script-from-within-a-script-874500/)

BigBoots623 04-12-2011 12:01 AM

Executing a script from within a script
 
How would I execute a shell script from within another. For instance I have one script that acts as a main menu, the user picks a choice from menu and if 'x' is picked then current menu is exited and 'x' script is run. THX

Walter.Stroebel 04-12-2011 12:13 AM

I suppose you mean something like this:
-------------------
#!/bin/bash
echo 1. hello
echo 2. bye
read a
if [ $a == "1" ] ; then hello.sh ; fi
if [ $a == "2" ] ; then bye.sh ; fi

grail 04-12-2011 12:39 AM

Unless the scripts are in your PATH, the above will not work and you will need to provide the path to the script.
You may also wish to have a look at the 'select' command.


All times are GMT -5. The time now is 11:50 AM.