天下网吧 >> 网吧天地 >> 网吧技术 >> 技术网管 >> 正文

通过批处理文件来远程维护你的服务器

昨天在微软的网站上看到了一个命令行方式下的端口扫描工具,down下来看了看,(你也可以到http://www.sometips.com/soft/portqry.exe下载)觉得这玩艺就操作性而言比其他同类产品差得太多,仔细一瞧,突然它居然有一个返回值的功能,这样岂不是可以在批处理文件里面来使用,呵呵,于是乎就写了个小小的脚本,希望能对大家有所帮助.


C:\scripts>type monitor.cmd
@echo off
setlocal
if {%1}=={} goto noparms
if {%2}=={} goto noparms

REM Please copy portqry.exe to the same folder with monitor.cmd.
portqry -n %1 -e %2 -q

IF %ERRORLEVEL% EQU 1 goto down
IF %ERRORLEVEL% EQU 0 goto up

:noparms
echo Usage: monitor.cmd ServerIP PortNumber
goto end

:up
echo The %2 port is listening on %1...
goto end

:down
echo The %2 port is not listening on %1...
goto end

:end


执行该脚本的结果:


C:\scripts>monitor.cmd
Usage: monitor.cmd ServerIP PortNumber
C:\scripts>monitor.cmd bbs.nsfocus.com 80
The 80 port is listening on bbs.nsfocus.com...
C:\scripts>monitor.cmd bbs.nsfocus.com 79
The 79 port is not listening on bbs.nsfocus.com...


你可以根据你自己的需要对这个脚本进行改动,Hope it helps...

附上PortQry的用法:


PortQry Usage:
PortQry.exe -n server [-p protocol] [-e || -r || -o endpoint(s)]
[-l logfile] [-s] [-q]

Where:
-n [server] IP address or name of server to query
-p [protocol] TCP or UDP or BOTH (default is TCP)
-e [endpoint] single port to query (valid range: 1-65535)
-r [end point range] range of ports to query (start:end)
-o [end point order] range of ports to query in an order (x,y,z)
-l [logfile] name of log file to create
-s 'slow link delay' waits longer for UDP replies from remote systems
-q 'quiet' operation runs with no output
returns 0 if port is listening
returns 1 if port is not listening
returns 2 if port is listening or filtered

Notes:
This version runs on Windows 2000 and Windows XP
Defaults: TCP, port 80, no log file, slow link delay off
Hit Ctrl-c to terminate prematurely


本文来源:佚名 作者:中国IT实验室收集整理

声明
声明:本站所发表的文章、评论及图片仅代表作者本人观点,与本站立场无关。若文章侵犯了您的相关权益,请及时与我们联系,我们会及时处理,感谢您对本站的支持!联系email:support@txwb.com,系统开号,技术支持,服务联系QQ:1175525021本站所有有注明来源为天下网吧或天下网吧论坛的原创作品,各位转载时请注明来源链接!
天下网吧·网吧天下
  • 本周热门
  • 本月热门
  • 阅读排行