Automatic logon and telnet settings for two platforms

Source: Internet
Author: User

Many of my friends asked me how to set automatic logon to telnet. Here we will introduce this operation. There are two platforms: Windows and Linux. We will introduce the process of automatic logon to telnet on both platforms. Hope to help you.

Automatic logon to telnet batch files

I. Automatic logon to telnet on Windows:

Copy the code to notepad and save it as autoTelnet. bat. Then, double-click it to automatically log on to the telnet server and modify the Server IP address.

 
 
  1. @echo off  
  2. echo set sh=WScript.CreateObject("WScript.Shell") >telnet_tmp.vbs  
  3. echo WScript.Sleep 300 >>telnet_tmp.vbs  
  4. echo sh.SendKeys "open 192.168.1.200" >>telnet_tmp.vbs  
  5. echo WScript.Sleep 300 >>telnet_tmp.vbs  
  6. echo sh.SendKeys "{ENTER}" >>telnet_tmp.vbs  
  7. echo WScript.Sleep 300 >>telnet_tmp.vbs  
  8. echo sh.SendKeys "engineer{ENTER}" >>telnet_tmp.vbs  
  9. echo WScript.Sleep 300 >>telnet_tmp.vbs  
  10. echo sh.SendKeys "ls {ENTER}">>telnet_tmp.vbs  
  11. start telnet  
  12. cscript //nologo telnet_tmp.vbs  
  13. del telnet_tmp.vbs 

Appendix:

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 %  

II. Automatic logon to telnet on Linux

Make sure that your system has an executable program, save the following code to the file autoTelnet, and grant the execution permission. Detailed operation view command audit CT

 
 
  1. #!/usr/bin/expect --  
  2. set SERVER "192.168.1"  
  3. set USER "myusername"  
  4. set PASSWD "mypass"  
  5. if { $argc } {  
  6. spawn telnet $SERVER.$argv  
  7. } else {  
  8. spawn telnet $SERVER.200  
  9. }  
  10. expect "Password:"  
  11. send "$PASSWD\n"  
  12. expect "#"  
  13. send "ls\n"  
  14. interact 

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.