Launching Python Script Process From Another Script On Ubuntu: How To Track Status?
I launch one Python script out of another one on an Amazon EC2 Ubuntu instance using a command: os.system(call) where call has the form './script2.py arg1 arg2 arg3' I've notice
Solution 1:
Assuming that your child script does not use standard output for something and returns non-zero on a crash (this should be default for python
executable though):
import subprocess as sp
try:
sp.check_output(['python', 'child.py'], stderr=sp.STDOUT)
except sp.CalledProcessError as err:
print'Child terminated abnormally with error %d, log:' % err.returncode
print err.output
Solution 2:
1> os.system returns the system code if it returns 0 process ran and terminated successfully but if it returns any number then generally it means an error but it depeds on how progam responds to the errors what i mean is if progam returns 1 on success os.system will return 1
for example
d = os.system('ls')
print d
d = os.system(your process)
print d
2> python provides syslog module you can try it like
>>>import syslog>>>help(syslog)
syslog is a buil-in unix api provided by the os itself
Post a Comment for "Launching Python Script Process From Another Script On Ubuntu: How To Track Status?"