So this is a script that I am coding for my buddies companies customer support. Basically, what it does is call using the IP phones that are in the script, it works, but with problems. Here is the code:
import urllib, urllib2, sys
num = sys.argv[1]
print 'Calling'
phones = [
'http://phone1/index.htm',
'http://phone2/index.htm',
'https://phone3/index.htm',
'https://phone4/index.htm',
'https://phone5/index.htm'
]
data = urllib.urlencode({"NUMBER":num, "DIAL":"Dial", "active_line":1})
while 1:
for phone in phones:
try:
urllib2.urlopen(phone,data) # make call
urllib2.urlopen(phone+"?dialeddel=0") # clear logs
except: pass
The first problem is that it only calls using phone one… Right now it is setup to keep calling over and over, for debugging purposes, and I seem to only be getting calls from phone one… The second problem is that the script will not terminate. ctrl+c does not work… The only way to terminate it (that I know of) is to end the ssh session. Now, I am new to python so both of these are probably just stupid mistakes so hopefully someone can help. Thanks!
Try replacing the try catch block like this,
While using the below code.
The system will catch SystemExit, KeyboardInterrupt and other things that you probably don’t want to catch.
Thanks.