对于Windows,是否有人在通过电子邮件发送公共IP地址时有脚本? [英] Does anyone have a script on emailing a public IP address whenever it changes, for Windows?

查看:195
本文介绍了对于Windows,是否有人在通过电子邮件发送公共IP地址时有脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于WINDOWS,是否有人在通过电子邮件发送公共IP地址时有脚本?我可能可以设置一个计划的任务来运行.

我不是编码器/脚本作者,但出于自动化目的,我想涉足该领域.我是一个聪明的人,我对新概念适应得很好,但是我在网络管理员方面接受了更多的培训(但我一直陷在软件支持部门的工作中).因此,如果我听起来不对劲或无知,请告诉我,但我将不胜感激.

我已经阅读了很多关于想要与我使用相同脚本的人的文章,但是它们始终是某种Bash脚本.我将Suse放在家里服务器上的虚拟盒子上,但似乎无法使bash脚本正常工作(坦率地说,我宁愿运行Windows脚本或批处理文件).我在路由器上设置了转发器,以便可以从任何地方远程访问,但是动态IP经常更改.我知道我可以设置一个免费域来管理该域,但是林先生对使它起作用很感兴趣,因为它很有趣.

我是新人,请描述一下.

谢谢

Does anyone have a script on emailing a public IP address whenever it changes, for WINDOWS? Possibly something that I can set up a schedualed task to run.

I am not a coder/scripter but I would like to get into it for automation purposes. Im a smart guy and I adapt well with new concepts but I am more trained on the network admin side of things (yet Im stuck in a software support desk job). So, if I sound out of place or ignorant let me know but I would appreciate the help.

I have read plenty of articles on people wanting the same script as me but they are always some kind of Bash script. I put Suse on a virtual box on my server at home but I can''t seem to get the bash script to work (frankly, I would rather have a windows script or batch file to run). I have a forwarder set up on my router so that I can remote in from where ever, but my dynamic IP changes often. I know I can set up a free domain to manage this but Im to interested on getting this to work because it is just more fun.

Im a newby, so be descriptive please.

Thanks

推荐答案

有人为我写了这个,它可以作为批处理文件很好地工作.您只需要修改电子邮件行,并确保在计算机上安装了cURL.exe和Blat.exe(cURL用于从网站上获取公共IP,而Blat用于发送电子邮件).我希望有人觉得这有用.

顺便说一句...我停顿了一下,这样我就能明白为什么它对我不起作用了(我看到我没有安装卷发和腮红).


@echo关闭
echo检查外部IP地址
如果存在ip.current del ip.current
curl-不安全https://secure.internode.on.net/webtools/showmyip?textonly=yes>> ip.current
如果不存在ip.old转到noold
设置/p ipold =< ip.old
回显找到存储的IP(%ipold%)
暂停
转到checkold
:noold
ren ip.current ip.old
设置/p ipcurrent =< ip.old
echo未找到存储的IP.节省当前IP(%ipcurrent%)
暂停
转到sendnote
:checkold
如果%ipold%==%ipcurrent%转到nonote
回显IP地址已更改
暂停
转到sendnote
:nonote
回声IP地址未更改
del ip.current
暂停
goto endscript
:sendnote
del ip.current
ren ip.current ip.old
blat.exe -f FROM@YOUR-EMAIL-ADDRESS.COM -t TO@YOUR-EMAIL-ADDRESS.COM -s"IPChange"-服务器您的SMTP-SERVER-ADDRESS-正文%ipcurrent%"
echo已发送电子邮件通知
暂停
:endscript
echo脚本完成
暂停
Someone wrote this up for me and it works great as a batch file. You just need to modify the email line and make sure you have cURL.exe and Blat.exe installed on your machine(cURL is used to grab the public IP off of the website and Blat is used to send the email). I hope someone finds this useful.

By the way... I put the pauses in so I could see why it wasnt working for me (i saw that i didnt have curl and blat installed).


@echo off
echo Checking External IP Address
if exist ip.current del ip.current
curl --insecure https://secure.internode.on.net/webtools/showmyip?textonly=yes >> ip.current
if not exist ip.old goto noold
set /p ipold= <ip.old
echo Stored IP found (%ipold%)
pause
goto checkold
:noold
ren ip.current ip.old
set /p ipcurrent= <ip.old
echo No Stored IP Found. Saving Current IP (%ipcurrent%)
pause
goto sendnote
:checkold
if %ipold% == %ipcurrent% goto nonote
echo IP Address has changed
pause
goto sendnote
:nonote
echo IP Address has not changed
del ip.current
pause
goto endscript
:sendnote
del ip.current
ren ip.current ip.old
blat.exe -f FROM@YOUR-EMAIL-ADDRESS.COM -t TO@YOUR-EMAIL-ADDRESS.COM -s "IPChange" -server YOUR-SMTP-SERVER-ADDRESS -body "%ipcurrent%"
echo Sent Email Notice
pause
:endscript
echo Script Complete
pause


这篇关于对于Windows,是否有人在通过电子邮件发送公共IP地址时有脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆