[root@ZHANG script]# cat setIp.py
#!/usr/bin/env python
import re
import os
import time
import random
ip_old = ''
while True:
currentIp = re.findall(r'\d+\.\d+\.\d+\.\d+',os.popen('curl -s http://ddns.oray.com/checkip').read())
print time.strftime("%Y-%m-%d %H:%M:%S")
print 'current ip is', currentIp
if currentIp and currentIp != ip_old:
print 'have new ip'
ip_old = currentIp
result= os.popen('curl -s http://account:password@ddns.oray.com/ph/update?hostname=23b7597c83.zicp.vip&myip='+str(currentIp )).read()
if 'good' in result:
print 'result: commit success'
elif 'nochg' in result:
print 'result: no change'
else:
print 'result: commit failed'
else:
print 'no cha