In many cases, we may need to log on to the Cisco switch to execute some common viewing commands, but it is troublesome to run cmd, enter the password, and enter the command.
The discovery can be achieved through batch processing, as shown in figureLog on to the Cisco switch 192.168.0.1 and Ping another switch 192.168.0.2.
The script is as follows:
@ 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
The Ping result is displayed immediately.
However, sometimes we want users to perform some tests and directly send the execution results to us in text;
This requiresRedirect debugging results to text filesPlease let me know about this. Thank you.