The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Invoking Oracle stored procedure in unix shell script hidnana Shell Programming and Scripting 1 10-15-2008 04:37 AM
returning to the parent shell after invoking a script within a script gurukottur Shell Programming and Scripting 5 09-26-2006 04:05 AM
Invoking Shell Script via php bubeshj Shell Programming and Scripting 2 06-30-2006 03:09 AM
Invoking shell script from html/jsp page bubeshj Shell Programming and Scripting 2 06-28-2006 10:53 AM
Wrong Shell Invoking My Script On Linux kowrip Shell Programming and Scripting 3 09-10-2003 07:18 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-18-2006
Registered User
 

Join Date: May 2006
Posts: 2
invoking one shell script from other

hi,

i am one day old in shell scritpting. how to invoke one shell script from the other?
For eg.i have two shell scripts A.sh and B.sh. Inside A.sh i need to invoke B.sh and the return code of A.sh should be the value returned by B.sh.

it would be better if you provide any sample shell scripts.

Thanks,
Ajay.
Reply With Quote
Forum Sponsor
  #2  
Old 05-18-2006
Registered User
 

Join Date: Jul 2002
Location: HK
Posts: 20
1.

A.sh call B.sh

just put
B.sh
as a command in the shell script e.g.
cp ... ...
ls ... ...
B.sh

etc...

Remeber the user running the script must also has execute permission for B.sh

2. The return value of A.sh
is controlled by either
exit <value>
or the return code of the last command
so if B.sh was you last command in A.sh then the return code of B.sh = return code of A.sh

However if you have more commands after B.sh in the script, you can save the return value of B.sh using

B.sh
retcode = $?
....
....
exit $retcode
(differs for whatever shell you use but $? is the return code of your last command.)

Hope it helps
Reply With Quote
  #3  
Old 05-19-2006
Registered User
 

Join Date: May 2006
Posts: 2
invoking one shell script from other

Thanks for your reply. but still i am having some doubts

i went through some of the websites. its quoted that "use $? very rarely".

is it a good practice to use this? (pradon me if i am wrong i dont have much idea in scripting)
Reply With Quote
  #4  
Old 05-24-2006
yogesh_powar's Avatar
Registered User
 

Join Date: Jun 2005
Location: satara
Posts: 37
Please ignore this!

another similar problem is

assume that
./a.sh will gives some output

./a.sh>a.out will redirect the output to some file a.out

Now i want to do same from another script insted of directly writting in prompt.
contents of b.sh will be

`./a.sh>a.out`

now when i run b.sh output is echoed to the screen insted of writing to a.out.
How come? Some solution to this

Last edited by yogesh_powar; 05-24-2006 at 12:55 AM. Reason: hey i got my mistake. please ignore this
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0