我在具有ADSL连接的机器上运行SSH.每次机器有新的IP地址时,我都会使用此脚本向我发送电子邮件.
我无法访问该机器.我把脚本给了一个朋友,所以我不能执行调试来弄清楚这个脚本有什么问题.我现在正在使用大学连接,它有一个静态IP地址.没有必要在它上面运行脚本.
所以任何建议如何改进/修复脚本.有时我会收到无效的IP地址,或者有时IP地址会改变,但我没有收到电子邮件.我应该使用其他方法进行这种自动化吗?
import urllib
import time
import smtplib
fromaddr = '***@gmail.com'
toaddrs = '***@gmail.com'
ip = ""
username = '****'
password = '****'
f = False
def update():
global ip,f
#print "sleeping 5 seconds"
time.sleep(5)
while not f:
try:
f = urllib.urlopen("http://automation.whatismyip.com/n09230945.asp")
except IOError, e:
print "no internet !"
time.sleep(5)
if not ip and f:
ip = f.read()
print "getting the first ip"
print ip
sendmail(ip)
print "mail sent"
else:
if f:
ip2 = f.read()
#print ip,ip2
if ip …Run Code Online (Sandbox Code Playgroud) 这是我的shiro配置
[main]
authc.loginUrl = /site/index.jsp
authc.usernameParam = user
authc.passwordParam = pass
authc.rememberMeParam = remember
authc.successUrl = /site/home.jsp
jdbcRealm=org.apache.shiro.realm.jdbc.JdbcRealm
jdbcRealm.permissionsLookupEnabled=true
jdbcRealm.authenticationQuery = select password from users where username = ?
jdbcRealm.userRolesQuery = select role from users where username = ?
credentialsMatcher = org.apache.shiro.authc.credential.HashedCredentialsMatcher
credentialsMatcher.hashAlgorithmName = SHA-256
credentialsMatcher.storedCredentialsHexEncoded = true
credentialsMatcher.hashIterations = 5000
jdbcRealm.credentialsMatcher = $credentialsMatcher
jof = org.apache.shiro.jndi.JndiObjectFactory
jof.resourceName = jdbc/postgres
jof.requiredType = javax.sql.DataSource
jof.resourceRef = true
jdbcRealm.dataSource = $jof
securityManager.realms = jdbcRealm
[urls]
/theme/** = anon
/site/** = authc
/site/cards.jsp …Run Code Online (Sandbox Code Playgroud)