Use login CT in shell script to implement telnet login to vrotelnet

Source: Internet
Author: User
Alibaba CT is based on TCL. As a scripting language, Alibaba CT can achieve automatic interaction (such as passwd, fsck, and telnet) without the participation of administrators ). Secondary CT can also be used to automatically test some applications. Here, the blogger uses login vro as an example. First, let's take a brief look at the process of using login CT to automatically log on to the vrotelnet through telnet. Of course, you can also use the login CT script ssh to log on to the server for automatic management. #! /Usr/bin/expectspawntelnet

Alibaba CT is based on TCL. As a scripting language, Alibaba CT can achieve automatic interaction (such as passwd, fsck, and telnet) without the participation of administrators ). Secondary CT can also be used to automatically test some applications.

Here, the blogger uses login vro as an example. First, let's take a brief look at the process of using login CT to automatically log on to the vrotelnet through telnet. Of course, you can also use the login CT script ssh to log on to the server for automatic management.

#!/usr/bin/expectspawn telnet 192.168.1.1expect"*Username:*"send"yourname\r"expect"*Password:*"send"yourpwd\r"send"en\r"expect"*password:*\r"send"yourpwd\r"send"sys show\r"send"exit\r"expect eof

Running the test is normal.

Spawn telnet 192.168.1.1
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.
Username: yourname
Password:

TP-LINK> en
Enter password:
# Sys show TP-LINK
CPU Used Rate: 17%

TP-LINK> exit
Connection closed by foreign host.


Related Article

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.