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