免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1392 | 回复: 0
打印 上一主题 下一主题

Windows下使用批处理实现对网站的监测 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-02 09:47 |只看该作者 |倒序浏览
由于多数监测软件是商业性质,同时使用过一个付费的监测服务感觉效果并不理想,于是动手弄了一个自己的监测系统,使用DOS批处理操作。

原理:
    使用了一个Wget.exe 的Win32版本用以从网站下载文件,利用批处理命令检测文件是否抓取成功,如果成功,删除已经下载的文件,退出批处理,如果不成功,利用安装在电脑上的modem拨打某个电话号码,使用特定的振铃次数通知网站发生故障。

    测试后将批处理放到windows中的计划任务中周期执行。

注意:wget.exe需要放置到与批处理相同的目录,或者放入windows系统目录。

批处理文件:

monitor.bat
@echo off
echo.>>wget.log
rem 使用wget下载网页首页文件,并记录日志
.\wget -a wget.log -d http://www.xxx.com   
rem 判断index.html文件是否下载成功
if exist index.html goto end
echo.>>system.log
echo ---------------------------->>system.log
date/t>>system.log&&time/t>>system.log
echo error occurred>>system.log
rem 调用一个拨号批处理
call .\dial.bat
exit

:end
echo.>>system.log
echo ---------------------------->>system.log
date/t>>system.log&&time/t>>system.log
echo ok>>system.log
echo y|del .\index.html
exit


dial.bat
@echo off
rem 使用at指令传送到串口拨号
echo atdtxxxxxxx >com1
rem 延时14秒,振铃3次
choice /c yn /d y /n /t 14 >nul
rem 挂机
echo ath>com1
choice /c yn /d y /n /t 5 >nul
echo atdtxxxxxxx >com1
choice /c yn /d y /n /t 14 >nul
echo ath>com1
choice /c yn /d y /n /t 5 >nul
echo atdtxxxxxxx >com1
choice /c yn /d y /n /t 14 >nul
echo ath>com1
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP