LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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

Reply
 
Search this Thread
Old 04-09-2010, 07:42 PM   #1
dedman
LQ Newbie
 
Registered: May 2007
Distribution: Suse/Kubuntu
Posts: 3

Rep: Reputation: 0
Question 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.
 
Old 04-09-2010, 07:54 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
Is google broken tonight ?
http://www.google.co.uk/search?num=2...=&oq=&gs_rfai=
 
0 members found this post helpful.
Old 04-09-2010, 07:57 PM   #3
dedman
LQ Newbie
 
Registered: May 2007
Distribution: Suse/Kubuntu
Posts: 3

Original Poster
Rep: Reputation: 0
Smile 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.
 
Old 04-09-2010, 08:44 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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.
 
Old 04-10-2010, 06:25 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,524
Blog Entries: 27

Rep: Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175
Quote:
Originally Posted by dedman View Post
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?
 
Old 04-12-2010, 06:11 PM   #6
dedman
LQ Newbie
 
Registered: May 2007
Distribution: Suse/Kubuntu
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by catkin View Post
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
 
Old 04-13-2010, 05:22 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,524
Blog Entries: 27

Rep: Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175
Quote:
Originally Posted by dedman View Post
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?
 
Old 04-24-2010, 08:53 PM   #8
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,019

Rep: Reputation: 63
Quote:
Originally Posted by dedman View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
calling director, bash script Spinoz Linux - Newbie 6 09-30-2009 07:23 PM
how to exit out of the calling Shell Script harimac Linux - Newbie 3 08-19-2009 01:49 AM
Calling PHP5 from a shell script Dafydd Programming 2 10-31-2008 07:31 PM
bash script calling mplayer afrodocter Programming 13 08-23-2005 10:41 AM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM


All times are GMT -5. The time now is 08:32 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration