I have a shell script TestNode.sh
. This script has content like this:
port_up=$(python TestPorts.py)
python TestRPMs.py
Now, I want to capture the value returned by these scripts.
TestPorts.py
def CheckPorts():
if PortWorking(8080):
print "8080 working"
return "8080"
elif PortWorking(9090):
print "9090 working"
return "9090"
But as I checked the answers available, they are not working for me. The print
is pushing the value in variable port_up
, but I wanted that print
should print
on the console and the variable port_up
should get the value from return statement. Is there a way to achieve this?
Note: I don't wish to use sys.exit()
. Is it possible to achieve the same without this?