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.

Did you search this forum ?

Try this:

 source B

inside script A

u can try capturing the

var=`./script <paramaneters>`
1 Like

How about script B finishing with a statement:-

exit your message number

This means that script A can contain:-

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

1 Like

Capture the values to an array, similar to what zozoo proposed, or read the output in a while loop.