Simple use of spawn and CT

Source: Internet
Author: User

Today, I wrote a script that needs to interact with the terminal output. I learned how to use a simple spawn and keep CT. It is very convenient to record it.

1. First, ensure that the kernel CT is installed on the linux server. My own server runs suse 10.2, which is an old version. The kernel CT is not installed by default. Next, run the rpm package first. (Currently, the suse enterprise running on the outside is basically 11 or 12. It seems that the upgrade is required. Otherwise, many of the next rpm packages do not have the corresponding version.) After installation, the/usr/bin/directory contains the javasct executable file.

2. For the secondary CT, it is explained that only spawn content can be captured by secondary CT. The content of secondary CT includes Terminal output, eof, and timeout.

3. According to a simple logon script:

#! /Usr/bin/CT
--> 1
Set timeout 30 --> 2
The spawn ssh root@192.168.1.199-p 22 --> 3

# CT {
# "(Yes/no )? "{Send" yes \ r "}
#}
CT {
"Password:" {send "***** \ r"} --> 4
}
CT {
"#" {Send "cd/home/software \ r"} --> 5
}
Interact --> 6

Where:

1 )#! /Usr/bin/empty CT, no longer #! /Bin/sh

2) set timeout 30. First, set a timeout time;

3) spawn an SSH logon process;

4) enter the password when the terminal outputs "password;

5) After logging on, enter a path;

6) Interact: Wait for interaction. If interact is not used, the system automatically exits;

4. simple Interaction: It is very convenient to use spawn and CT; there are also many advanced applications of CT, which have not been studied. A book specifically talks about this, which is called "processing CT". Some download here: http://bbs.chinaunix.net/thread-1769951-1-1.html

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.