Hi, wondering if anyone has a more efficient way of sending an email when a python script has crashed. I have several scripts that run on a remote machine and would like to know when they fail.My method is very crude and doesn't work quite right.Currently using a Try/Except which creates a .BAT file, the .BAT file runs a SQLPLUS statement that executes an Oracle function which sends me an email. There must be a better way.try:
print "doing some stuff"
except:
f = open('c:\\Fail_Notification.BAT', 'w')
f.write("c:\n")
f.write("cd" + "\\\n")
f.write('SQLPLUS DB_USER/PASSWORD@DB1 @\\\\scripts\\python\\fail_notification.sql \"Frank@Hotmail.com\" \"Script has failed.\"')
f.close()
os.spawnv(os.P_WAIT, 'c:\\projects\\Fail_Notification.BAT', [])
os.remove('c:\\Fail_Notification.BAT')