Learn Batch telnet to get twice the result with half the effort

Source: Internet
Author: User

For network administrators, managing dozens or hundreds of hosts, routers, switches, and other things by one person is also common. How can we manage them? This requires Batch. Now we will introduce the Batch telnet settings. I believe it will be useful for administrators.

Generally, there are two methods:

1. Windows Script Host using VBS)

2. Automatic Terminal Method for some terminals that can be configured with automatic telnet)

Here we will discuss the first method: The VBS method. Because the Windows Script Host is provided by the system, we can do it without installing local software. Therefore, it is generally the first choice to solve the problem.

First, we create a script named tel. vbs. Here we use Batch to telnet to the cisco router as an example. You can modify the relevant content.

 
 
  1. 'Create Shell object
  2.  
  3. Set sh = WScript. CreateObject ("WScript. Shell ")
  4. WScript. Sleep 1000
  5. 'Send the commands we input to telnet
  6. Sh. SendKeys "open 192.168.1.1"
  7. WScript. Sleep 1000
  8. Sh. SendKeys "{ENTER }"
  9. WScript. Sleep 1000
  10. Sh. SendKeys "password {ENTER }"
  11. WScript. Sleep 1000
  12. Sh. SendKeys "en {ENTER }"
  13. WScript. Sleep 1000
  14. Sh. SendKeys "passord {ENTER }"
  15. WScript. Sleep 1000
  16. 'Run the cisco show run Command
  17. Sh. SendKeys "show run {ENTER }"

Then, create a batch_tel.bat batch file:

 
 
  1. Rem start telnet
  2. Start telnet.exe
  3. Rem batch telnet
  4. Cscript // nologo tel. vbs

Finally, we only need to run batch_tel.bat to easily handle the Batch telnet operation.

For what the SendKeys command can send, we can look at the following list:

 
 
  1. BACKSPACE {BACKSPACE}, {BS}, or {BKSP}  
  2. BREAK {BREAK}  
  3. CAPS LOCK {CAPSLOCK}  
  4. DEL or DELETE {DELETE} or {DEL}  
  5. DOWN ARROW {DOWN}  
  6. END {END}  
  7. ENTER {ENTER}or ~  
  8. ESC {ESC}  
  9. HELP {HELP}  
  10. HOME {HOME}  
  11. INS or INSERT {INSERT} or {INS}  
  12. LEFT ARROW {LEFT}  
  13. NUM LOCK {NUMLOCK}  
  14. PAGE DOWN {PGDN}  
  15. PAGE UP {PGUP}  
  16. PRINT SCREEN {PRTSC}  
  17. RIGHT ARROW {RIGHT}  
  18. SCROLL LOCK {SCROLLLOCK}  
  19. TAB {TAB}  
  20. UP ARROW {UP}  
  21. F1 {F1}  
  22. F2 {F2}  
  23. F3 {F3}  
  24. F4 {F4}  
  25. F5 {F5}  
  26. F6 {F6}  
  27. F7 {F7}  
  28. F8 {F8}  
  29. F9 {F9}  
  30. F10 {F10}  
  31. F11 {F11}  
  32. F12 {F12}  
  33. F13 {F13}  
  34. F14 {F14}  
  35. F15 {F15}  
  36. F16 {F16}  
  37. SHIFT +  
  38. CTRL ^  
  39. ALT % 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.