Return output from shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Return output from shell script
# 1  
Old 12-02-2013
Return output from shell script

Hi All,

There are 2 scripts A and B.

A --> It will invoke script B

B -->

It will generate below output.

100 - connected
105 - Not Connected
210 - Connected

I want to return this value to script A. Please advice.
# 2  
Old 12-02-2013
Did you search this forum ?

Try this:
Code:
 source B

inside script A
# 3  
Old 12-02-2013
u can try capturing the

Code:
var=`./script <paramaneters>`

This User Gave Thanks to zozoo For This Post:
# 4  
Old 12-02-2013
How about script B finishing with a statement:-
Code:
exit your message number

This means that script A can contain:-
Code:
scriptB
ret_from_B=$?
case $ret_from_B in
   100) print "I have a message from script B"
        print "100 - connected"                    ;;
   105) print "I have a message from script B"
        print "105 - not connected"                ;;
   200) print "I have a message from script B"
        print "200 - Connected"                    ;;
   *)   print "Unexpected return code"             ;;
esac

The return code / value in the exit statement must be a single numeric value.


I hope that this helps.

Robin
Liverpool/Blackburn
UK
This User Gave Thanks to rbatte1 For This Post:
# 5  
Old 12-02-2013
Capture the values to an array, similar to what zozoo proposed, or read the output in a while loop.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Return Code to shell script

Hi, I need to send the return code from a script to the parent shell script. But i am suppressing outputs while calling the child script. Is there any way still to get the return code from the child script with suppress output. Below is my script: I am using :$ while calling return.sh... (5 Replies)
Discussion started by: usrrenny
5 Replies

2. Shell Programming and Scripting

Need output of script on screen and file with correct return status of the called script.

Hi, I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed. Below is my sample... (14 Replies)
Discussion started by: Prathmesh
14 Replies

3. Shell Programming and Scripting

How to return programming to calling shell script?

Hi, I need to edit a shell script which is calling another shell script. At the moment the program returns to the command prompt after executing each called script. I need to change it to make it return to the calling script so that the user is able to make another choice to execute the next... (11 Replies)
Discussion started by: PTL
11 Replies

4. Shell Programming and Scripting

*ix script to check port of client server and return output

Hello EveryOne, I am new to *ix. some could help to write a script. Problem :- Have to ssh to so many client and check port or filesystem usage, so thinking to automate using script. What i Need:- when i run script on my Launchpad server, it should Should ask and SSH to user provided... (3 Replies)
Discussion started by: MeFirst
3 Replies

5. Shell Programming and Scripting

Return to HTML file from shell script

Hi! I'm writing a simple script which I call on using a simple html button. The script also recives a simple argument. After the script is done I immediately want to return to my html page. But I dont know how to do that! #!/bin/sh echo "Content-type: text/html" echo "" if then echo... (1 Reply)
Discussion started by: crille
1 Replies

6. Shell Programming and Scripting

Return Value from a FTP shell script

Hello folks,,, I am calling a Unix shell script from java. The unix script is transferring a file through FTP. I wonder how can I confirm whether the script has been executed properly without any error. Is there any way to find the return value from the script. My FTP script is given below ... (3 Replies)
Discussion started by: dinesh1985
3 Replies

7. Shell Programming and Scripting

How to return a value of a variable from shell script to perl script

HI , Is there any way to return a value of variable from shell to perl script. Code: === Perl file my $diff1=system("sh diff.sh"); my $diff2=system("sh diff1.sh"); I need exit status of below commands i.e 0 and 1 respectively. Since in both the cases diff is working so system... (3 Replies)
Discussion started by: srkelect
3 Replies

8. Shell Programming and Scripting

return status after run the shell script

Hello, I wanted to delete all files which are placed 14 days back. Here is my below script. My script works very well and it deletes all files 14 days back. I wanted to display message incase if the delete script is not successful. The below script returns always successful. But the directory... (6 Replies)
Discussion started by: govindts
6 Replies

9. Shell Programming and Scripting

How to return the value from the called shell script to the calling sh script

Hi all, I have two ksh scripts #sample1.sh #!/bin/ksh . ./sample2.sh echo $fileExist #sample2.sh #!/bin/ksh func() { i=1 return $a } func echo $? Here how should I return the value of sample2.sh back to sample1.sh? Thanks in advance. (2 Replies)
Discussion started by: gp_singh
2 Replies

10. Shell Programming and Scripting

How to return value in shell script

im using bourne shell In file scriptA i add a new function, test_return() test_return() { a=1 return $a } when i try execute , a='/''/scriptA test_return echo $a its give me error.. scriptA: cannot return when not in function ist any solution for this problem.. How... (1 Reply)
Discussion started by: neruppu
1 Replies
Login or Register to Ask a Question