How to Use the TTL script of limit term

Source: Internet
Author: User

1. Environment Construction

1. Install the additional term.

The download path is as follows:

Http://logmett.com/index.php? /Download/tera-term-469.html

2. Install a running PFC Environment

2. Use the TTL script for Automatic Testing


For more information about TTL script naming, see the Help File of limit term.

 

TTL script method:

The script is relatively simple, and I will not talk about it. I will briefly introduce several commands that are basically used.

A. connect to and disconnect the machine on which the PFC is located using the disconnect term.

Use the connect/disconnect command of TTL.

Connect:

Connect '2017. 168.137.27/ssh/auth = PASSWORD/user = username/passwd = passwd'

Note: username is the user name and passwd is the password.

Disconnect:

Disconnect
0

Note: The parameter 0 is specified after disconnect, so the confirmation box is not displayed.

B. Record the entire operation process through the log, and finally confirm the test result by comparing the log.

Use the logopen/logclose command to write logs

Logopen:

Logopen filename 0 1 1

Note: It is best to set filename to the command name. Do not repeat the TTL script without passing through. It can also take the execution time,

Example: show_candidate_config _
20110316-130939.log

The method is as follows:

Gettime timestr "% Y % m % d-% H % m % s"

Getdir mdir

Sprintf2 filename '% s \ show_candidate_config _ % S. log' mdir
Timestr

Logclose:

Logclose

C. commands that may be used for testing

Pause: (pause)

Pause <time> remarks: pauses for <time> seconds.

Sendln: (send command and line feed)

Sendln <data1> <data2>... remarks: Causes used term to send characters followed by a new-line character to the host.

Send :( send command)
Send <data1> <data2>... remarks: Causes resume term to send characters to the host.
If <DATA> is a string, the string is sent to the host.
If <DATA> is an integer, its lowest-order byte (0-255) is regarded as an ascii code of the character, and the character is sent to the host.
For example, the command to press the tab key is send
#9
Wait: (wait for the matched string to appear)
Wait <string1> [<string2>...] remarks: pauses until one of the character strings is stored ed from the host, or until the timeout occurs. Maximum number
The strings is 10.

Note: To use this command, you need to set the timeout time. The returned results of the command are stored in the resault variable,

When resault is 0, the request times out. The timeout setting command is as follows:

Timeout = 1
/* The value after the equal sign is an integer. If it is set to negative, it is an infinite wait */

Waitln: (wait for the entire line to match the string to appear)
Waitln <string1> [<string2>...] remarks: pauses until a line which contains one of the character strings is stored ed from the host, or until the timeout occurs.
Maximum number of the strings is 10. Note the same as above
For other commands such as if, then, elseif, else, endif, and Goto, see the Help file.
Notes for script generationA.
The specified log file names in different TTL scripts cannot be repeated. B.
In the last part of the script, clear the test environment so that the next TTL script can be executed. C.
Append the pause command D when running slowly, for example, connecting to a machine.
The script should be concise and short as possible, so that it is easy to change when the style is changed. E.
You can add comments when necessary.

Example:

1. Create a BAT file in the window,

"C: \ Program Files \ teraterm \ ttpmacro.exe" "D: \ My kownhow \ TTL \ test. TTL"
Exit

2. Generate the TTL script file test. TTL.

#### Connect Host
Connect '2017. 28.92.23/ssh/auth = PASSWORD/user = root/passwd = password'

Pause 1

#### Create log

Gettime logstr "log-policyunctd-hangzhouhuncs.txt"
Getdir curdir
Sprintf '% s \ % s' curdir logstr
Filename = inputstr
Logopen filename 0 1 1
Logwrite 'Log start' #13 #10

Looptimes = 1;
While looptimes <11
#### Run cmd

Sendln "ls-l"
Wait "#"
Looptimes = looptimes + 1
Endwhile

#### Closelog
Logclose

#### Disconnect
Disconnect
Closett

Execute the BAT file to run the TTL script. (End)

 

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.