Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
04-09-2010, 07:42 PM
|
#1
|
LQ Newbie
Registered: May 2007
Distribution: Suse/Kubuntu
Posts: 3
Rep:
|
Calling a bash shell script from within another script
I am trying to call a script say mkdir.sh into another script that will make use of the dir's which are created in the first script. I know that I could code it all together, but I am trying to avoid rewriting the mkdir script as it is long. any help would be great.
Last edited by dedman; 04-09-2010 at 07:47 PM.
|
|
|
04-09-2010, 07:54 PM
|
#2
|
Senior Member
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279
|
|
|
0 members found this post helpful.
|
04-09-2010, 07:57 PM
|
#3
|
LQ Newbie
Registered: May 2007
Distribution: Suse/Kubuntu
Posts: 3
Original Poster
Rep:
|
Tried Google
Didn't type it the way you did though, thanks.
Didn't help much I'll keep trying
Last edited by dedman; 04-09-2010 at 08:10 PM.
|
|
|
04-09-2010, 08:44 PM
|
#4
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
A shell script can call any legal command, even if it is another script. Just be sure all the required permissions are set and that the called items are in $PATH, or are called with full pathnames.
|
|
|
04-10-2010, 06:25 AM
|
#5
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Quote:
Originally Posted by dedman
I am trying to call a script say mkdir.sh into another script that will make use of the dir's which are created in the first script. I know that I could code it all together, but I am trying to avoid rewriting the mkdir script as it is long. any help would be great.
|
I don't understand what you want to do. Do you want to call mkdir.sh from a script (let's call it a.sh) and have mkdir.sh make some directories and then have a.sh somehow get the names of the new directories? Will a.sh tell mkdir.sh which directories to make? How could anybody find out which directories mkdir.sh makes? Does it report what it is doing on stdout?
|
|
|
04-12-2010, 06:11 PM
|
#6
|
LQ Newbie
Registered: May 2007
Distribution: Suse/Kubuntu
Posts: 3
Original Poster
Rep:
|
Quote:
Originally Posted by catkin
I don't understand what you want to do. Do you want to call mkdir.sh from a script (let's call it a.sh) and have mkdir.sh make some directories and then have a.sh somehow get the names of the new directories? Will a.sh tell mkdir.sh which directories to make? How could anybody find out which directories mkdir.sh makes? Does it report what it is doing on stdout?
|
Basically the mkdir.sh will make dir's which have been predetermined in the script. Then a.sh would call mkdir to run, and then sort through files in yet another dir and place them into the newly created dir's according to guidelines setforth by a.sh
|
|
|
04-13-2010, 05:22 AM
|
#7
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
Quote:
Originally Posted by dedman
Basically the mkdir.sh will make dir's which have been predetermined in the script. Then a.sh would call mkdir to run, and then sort through files in yet another dir and place them into the newly created dir's according to guidelines setforth by a.sh
|
That's good information. You can put a command in a.sh to call mkdir.sh, exactly as you would call mkdir.sh from the command line ... OK?
|
|
|
04-24-2010, 08:53 PM
|
#8
|
Senior Member
Registered: Sep 2007
Posts: 1,047
Rep:
|
Quote:
Originally Posted by dedman
Basically the mkdir.sh will make dir's which have been predetermined in the script. Then a.sh would call mkdir to run, and then sort through files in yet another dir and place them into the newly created dir's according to guidelines setforth by a.sh
|
You can call any script as you call it in terminal.
Make sure the script is executable.
|
|
|
All times are GMT -5. The time now is 10:56 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|