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