// IP Address Regex http://www.regular-expressions.info/examples.html
currentIp = (
"http://whatsmyip.us/"
.toURL().text =~ /\b\d{
1
,
3
}\.\d{
1
,
3
}\.\d{
1
,
3
}\.\d{
1
,
3
}\b/)[
0
]
println
currentIp
def
ipLog =
new
File(
"ip-log.txt"
)
recentIp = ipLog.readLines().last().
tokenize
(
","
).last().trim()
if
(currentIp != recentIp) {
Mailer.deliverIpAddressChangeMessage currentIp
println
"IP Address has changed, it is now: ${currentIp}. Sending Message."
本文介绍了一个用于检测IP地址变化并记录的脚本。通过正则表达式从特定网站抓取IP地址,若发现IP地址发生变化,则发送邮件通知。此脚本适用于需要监控IP地址变动的场景。
203

被折叠的 条评论
为什么被折叠?



