Reputation: 59
Running python code through Control-M Jobs.If below code exit with status 7 in python. Control-m should capture code and on do Action if status 7 then code should set As Ok and should mail through Control-m.
try:
fh = open("testfile", "r")
fh.write("This is my test file for exception handling!!")
except IOError:
print "Error: can\'t find file or read data"
exit(7)
Code is terminating with exit status 7 but in control-m not able to capture exit status. In Control-m, On do Action i added if status 7 then Job should Set As Ok and should send mail.
Can someone help me how Control-M can capture Python code exit status?
Upvotes: 2
Views: 1236
Reputation: 31
The working code would look like this (based on Amiram's comment)
import sys
try:
fh = open("testfile", "r")
fh.write("This is my test file for exception handling!!")
except IOError:
print "Error: can\'t find file or read data"
sys.exit(7)
Upvotes: 2
Reputation: 5982
You can run script with bashscript and echo exitcode of python script.
Upvotes: 0