发现其实可以通过建立批处理来实现,如登陆到cisco交换机192.168.0.1然后ping另外一台交换机192.168.0.2
脚本如下:
@echo off
echo set sh = WScript.CreateObject( " WScript.Shell " ) > telnet_tmp.vbs
echo WScript.Sleep 300 >> telnet_tmp.vbs
echo sh.SendKeys " open 192.168.0.1 " >> telnet_tmp.vbs
echo WScript.Sleep 300 >> telnet_tmp.vbs
echo sh.SendKeys " {ENTER} " >> telnet_tmp.vbs
echo WScript.Sleep 300 >> telnet_tmp.vbs
echo sh.SendKeys " root{ENTER} " >> telnet_tmp.vbs
echo WScript.Sleep 300 >> telnet_tmp.vbs
echo sh.SendKeys " YOUR_PASSWORD{ENTER} " >> telnet_tmp.vbs
echo sh.SendKeys " ping 192.168.0.2{ENTER} " >> telnet_tmp.vbs
start telnet
cscript // nologo telnet_tmp.vbs
echo del telnet_tmp.vbs
echo set sh = WScript.CreateObject( " WScript.Shell " ) > telnet_tmp.vbs
echo WScript.Sleep 300 >> telnet_tmp.vbs
echo sh.SendKeys " open 192.168.0.1 " >> telnet_tmp.vbs
echo WScript.Sleep 300 >> telnet_tmp.vbs
echo sh.SendKeys " {ENTER} " >> telnet_tmp.vbs
echo WScript.Sleep 300 >> telnet_tmp.vbs
echo sh.SendKeys " root{ENTER} " >> telnet_tmp.vbs
echo WScript.Sleep 300 >> telnet_tmp.vbs
echo sh.SendKeys " YOUR_PASSWORD{ENTER} " >> telnet_tmp.vbs
echo sh.SendKeys " ping 192.168.0.2{ENTER} " >> telnet_tmp.vbs
start telnet
cscript // nologo telnet_tmp.vbs
echo del telnet_tmp.vbs
如此可以立即显示ping的结果。
但有时候我们希望用户做一些测试,希望用户直接将执行的结果以文本的方式发给我们;
这就需要把调试结果重定向到文本文件,这点有清楚的麻烦告知啊,谢谢先。