The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 07:37 AM
returning to the parent shell after invoking a script within a script gurukottur Shell Programming and Scripting 5 09-26-2006 07:05 AM
Invoking Shell Script via php bubeshj Shell Programming and Scripting 2 06-30-2006 06:09 AM
Invoking shell script from html/jsp page bubeshj Shell Programming and Scripting 2 06-28-2006 01:53 PM
Wrong Shell Invoking My Script On Linux kowrip Shell Programming and Scripting 3 09-10-2003 10:18 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-18-2006
ajay xavier ajay xavier is offline
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.
  #2 (permalink)  
Old 05-18-2006
azrealhk azrealhk is offline
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
  #3 (permalink)  
Old 05-19-2006
ajay xavier ajay xavier is offline
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)
  #4 (permalink)  
Old 05-24-2006
yogesh_powar's Avatar
yogesh_powar yogesh_powar is offline
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 03:55 AM.. Reason: hey i got my mistake. please ignore this
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0