设为首页 | 收藏本页
登陆您的帐号 | 免费注册帐号
全部栏目 > 计算机 > 软件 > 人工智能
下一篇上一篇 首页图文展示(无图)

Windows下使用批处理实现对网站的监测

发布人:hy58
发布日期:2015-06-06 09:02:18
刷新日期:2015-06-06 09:02:18
回复或评论:0
阅览:253
由于多数监测软件是商业性质,同时使用过一个付费的监测服务感觉效果并不理想,于是动手弄了一个自己的监测系统,使用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    
评论(0) 暂无回帖


打印 收藏 关闭窗口 下一篇上一篇