小编abd*_*bdu的帖子

自动更新和发送IP地址

我在具有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)

python networking automation

3
推荐指数
1
解决办法
1887
查看次数

shiro与jdbc和散列密码

这是我的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)

java hash jsp jdbc shiro

3
推荐指数
1
解决办法
2886
查看次数

标签 统计

automation ×1

hash ×1

java ×1

jdbc ×1

jsp ×1

networking ×1

python ×1

shiro ×1