首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VBA >

xp下如何使用批处理自动telnet到服务器上,并执行命令

2012-02-12 
xp下怎么使用批处理自动telnet到服务器上,并执行命令?rt[解决办法]::@echo offexitset hostipxx.xx.xx.xx

xp下怎么使用批处理自动telnet到服务器上,并执行命令?
rt

[解决办法]

::@echo off exit
 


set hostip=xx.xx.xx.xx
set osusr=cisco
set ospwd=cisco
set /a sleeptime=500

:: 登陆, "~"代表回车

echo Set sh = CreateObject("WScript.Shell") > %tmp%\tel_%hostip%.vbs
echo sh.Run "telnet -f dkzt.txt %hostip%" >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys "%ospwd%~" >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys "en~" >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys "%ospwd%~" >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs

:: 设置命令

echo sh.SendKeys "sh ip int bri~" >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs

echo sh.SendKeys " " >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys " " >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys " " >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys " " >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys " " >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys " " >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys " " >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys " " >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys " " >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs

echo sh.SendKeys "exit~" >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs
echo sh.SendKeys " ~" >> %tmp%\tel_%hostip%.vbs
echo WScript.Sleep(%sleeptime%) >> %tmp%\tel_%hostip%.vbs

start cscript /nologo %tmp%\tel_%hostip%.vbs
::del /q %tmp%\tel_%hostip%.vbs

热点排行