Return a value from shell script when it is called from a python script -
i have shell script abc.sh called python script custom_package.py using subprocess.call function call. want return value abc.sh , read in python.
python call shell script follows.
subprocess.call(['abc.sh', user, password]) abc.sh echos "running" or "not running". how can capture "running" or "not running" in python script? like:
ret_val = subprocess.call(['abc.sh', user, password]) i have tried subprocess.check_output it's not working.
ret_val = subprocess.check_output(['abc.sh', user, password])
use subprocess.check_output capture output of subprocess. if string 'not' not in returned value, output 'running'.
output = subprocess.check_output(['abc.sh', user, password]) print(output) running = 'not' not in output
Comments
Post a Comment