Get Terminal Text

Declaration

<AMGETTERMTEXT SESSION="text" RESULTVARIABLE="text" ACTION="RANGE" BEGINROW="number" BEGINCOL="number" ENDROW="number" ENDCOL="number" />

See Also

Connect Terminal | Control Terminal | Disconnect Terminal | Send Terminal Text | Wait Terminal

Description

Retrieves text from the terminal during an established terminal session and populates a variable with the results. This action can be set to retrieve text from the entire screen, the current line, a specified line, or a specified range.

Practical Usage

Generally used to get text from an existing terminal session that was previously created by a Connect Terminal step. The terminal actions are used in lieu of terminal emulation software. With the use of the terminal actions, legacy systems can be automated in the background without the use of 3rd party software.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

Text to Get

Text (options)

No

Entire screen

ACTION="CURRENTLINE"

The location from which to retrieve the text. The available options are:

  • Current line: Retrieves the line of text from the current cursor position.

  • Entire screen (default): Retrieves text from the full displayed screen.

  • Specific line: Retrieves text from the specified line.

  • Range: Retrieves a range specified by Beginning row, Beginning column, Ending row, and Ending column parameters.

Line

Number

Yes if Text to Get is Specific line

(Empty)

LINE="4"

The line number to retrieve text from. This parameter is available only if the Text to Get parameter is set to Specific line.

Beginning Row

Number

Yes if Text to Get is  Range

(Empty)

BEGINROW="11"

The beginning row of the range of text to get. This parameter is available only if the Text to Get parameter is set to Range.

Beginning Column

Number

Yes if Text to Get is Range

(Empty)

BEGINCOL="3"

The beginning (left) column of the range of text to get. This parameter is available only if the Text to Get parameter is set to Range.

Ending Row

Number

Yes if Text to Get is  Range

(Empty)

ENDROW="24"

The ending row of the range. This parameter is available only if the Text to Get parameter is set to Range.

Ending Column

Number

Yes if Text to Get is  Range

(Empty)

ENDCOL="20"

The ending (right) column of the range. This parameter is available only if the Text to Get parameter is set to Range.

Place Buffer into Variable

Text

Yes

(Empty)

RESULTVARIABLE="Var1"

The name of the variable in which to place the retrieved text.

Session Name

Text

No

TermSess1

SESSION="TermSess2"

The session name from which to get the text. This session name must have been previously created with a Connect Terminal step. This allows several connections to be active simultaneously. If you are only using one connection at a time, do not specify a value other than the default.

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties lets you instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables & Functions

A percent sign is used as a special character in AutoMate to indicate the beginning and end of an expression. This allows variables, functions and other expressions to be entered in any text parameter of a task's properties. For example: %1+1% inside a task will resolve to 2 at runtime. A more elaborate example is %FileDateTime(myFile)% which results to the date/time of myFile. To help construct expressions, you can open Expression Builder by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on functions

More on extended functions
More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Sample 1 - Get the contents of line 3 on terminal "mySession" and place into the variable "var1".

 

<AMGETTERMTEXT SESSION="mySession" RESULTVARIABLE="var1" ACTION="LINE" LINE="3" />

 

 

 

Sample 2 - A sample task that uses all available terminal actions. Examining the step parameters and properties of this task may assist you in creating your own terminal emulation task.

 

<AMVARIABLE NAME="thePassword">password</AMVARIABLE>

<AMCONNECTTERM EMULATION="VT220" HOST="linux.networkautomation.com" SHOWTERMINALWINDOW="YES" />

<AMWAITFORTERMTEXT TYPE="TEXT">login:</AMWAITFORTERMTEXT>

<AMSENDTERMTEXT>%theUsername%{ENTER}</AMSENDTERMTEXT>

<AMSHOWDIALOG>OK to proceed?</AMSHOWDIALOG>

<AMWAITFORTERMTEXT TYPE="TEXT">Password:</AMWAITFORTERMTEXT>

<AMSENDTERMTEXT>%thePassword%{ENTER}</AMSENDTERMTEXT>

<AMSHOWDIALOG>OK to proceed?</AMSHOWDIALOG>

<AMDISCONNECTTERM />

 

↑ Top of Page