Automated CT is a software suite for automatic interaction (Automated CT [is a] software suite for automatic interactive tools ).
The Except CT language is based on TCL. As a scripting language, TCL has simple Syntax:
CMD Arg
A tcl command consists of words separated by spaces. The first word is the command name, and the rest are the command parameters.
The script code is as follows:
######################################## ######
#! /Usr/bin/CT
Set timeout 30
Spawn ssh-l username 192.168.1.1
Reset CT "Password :"
Send "ispass \ r"
Interact
######################################## ######
1 .[#! /Usr/bin/CT]
This line tells the code in the operating system script to use that shell for execution. The objective CT is similar to bash in Linux and CMD in windows.
Note: This line must be in the first line of the script.
2. [set timeout 30]
Basically, anyone who knows English knows that this is the time-out period. Now you only need to remember that the unit of time is second.
3. [spawn ssh-l username 192.168.1.1]
Spawn is the internal CT command that can be executed only after entering the CT environment. If the CT is not installed or the spawn command cannot be found directly in the default shell. Therefore, do not use commands such as "which spawn" to find the spawn command. For example, in windows, DIR is an internal command that comes with shell. You cannot find an executable file of dir.com or dir.exe.
Its main function is to add a shell to the SSH running process to transmit interactive commands.
4. [Keep CT "Password:"]
The secondary CT command is also an internal command of secondary CT. It is a bit dizzy. The shell command of secondary CT is the same as the internal command, but it is not a function and it is just a habit. This command is used to determine whether the output result contains a string of "Password:". If yes, return immediately; otherwise, return after a period of time, the waiting duration is the last 30 seconds.
5. [Send "ispass \ r"]
The interaction is performed here, which is equivalent to the password input.
Tip: do not add "\ r" to the end of the command string. If an exception occurs, check it.
6. [interact]
After the execution is complete, the interaction status is maintained, and the control is handed over to the console. At this time, you can perform manual operations. If this statement is not entered, the system will exit after logon, instead of staying on the remote terminal. If you log on and run a command to exit, you can change it to [Login ct eof].
Note:
Currently, you can only use the login CT script to log on to the remote shell instead of exiting (the script is as above), so you cannot use login CT to log on to the remote shell instead of exiting in the bash script.