i am running a curl command to check the status of a website:
try:
connectionTest = subprocess.Popen([r"curl --interface xx.xx.xx.xx http://www.yahoo.com"], shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
cstdout,cstderr = connectionTest.communicate()
if cstdout:
#print cstdout
status = "OK"
elif cstderr:
#print cstderr
status = "PROBLEM"
except:
e = sys.exc_info()[1]
print "Error: %s" % e
The code works fine except for the try:except statement as its not catching the exception properly, below is the output of the script when the interface is down, now i would like to catch that first line in the except statement... instead it being spawned...is this possible??
SIOCSIFFLAGS: Cannot assign requested address
PROBLEM