LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 04-12-2011, 12:01 AM   #1
BigBoots623
LQ Newbie
 
Registered: Apr 2011
Posts: 5

Rep: Reputation: 0
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
 
Old 04-12-2011, 12:13 AM   #2
Walter.Stroebel
LQ Newbie
 
Registered: Apr 2011
Location: Arnhem, The Netherlands
Distribution: CentOS
Posts: 19

Rep: Reputation: 6
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
 
Old 04-12-2011, 12:39 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 07:58 PM
Bash Script - executing answer to another script domz Programming 4 11-07-2010 04:19 PM
Run an external script, without holding up the currently executing script onesikgypo Programming 2 03-07-2009 09:26 PM
need help executing a script that someone sent me giantjoebot Linux - Newbie 16 08-13-2008 12:35 AM
Bash script - executing a script through subdirectories bubkus_jones Programming 5 04-24-2006 05:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration