Send Terminal Text

Declaration

<AMSENDTERMTEXT SESSION="text" WAITFORDEFAULTPROMPT="text [options]">text</AMSENDTERMTEXT>

See Also

Connect Terminal, Disconnect Terminal, Send Terminal Text, Wait Terminal, Control Terminal

Description

Sends text to the terminal starting at the current cursor position during an established Terminal session. This action can be set to wait until the terminal is ready to receive the next command before sending text.

Practical Usage

Used to send text into an existing terminal session that was previously created by Connect Terminal action. The terminal actions are used in leu of terminal emulation software. Using 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

Text

Yes

(Empty)

 

>Smith</AMSENDTERMTEXT>

The text to send to the terminal. For example, if the terminal prompt was requesting a last name, this parameter could be "Smith" (no quotes).

Session Name

Text

No

TermSess1

SESSION="MyTermSession"

The session name to send this text to. This session name must have been previously created with a prior Connect Terminal step. This allows several connections to be active simultaneously. If you are only using one connection at a time, you can leave this parameter set to the default value -TermSess1.

Wait for default prompt

Text (options)

No

Do not wait

WAITFORDEFAULTPROMPT="BEFORE"

Specifies whether task execution should pause before and/or after text is sent to the terminal and wait for the appearance of the default prompt. Often, this option is needed to cause the task to wait until the terminal is ready to receive the next command before sending text. The available options are:

  • Do not wait (default): The task will not wait for the default prompt.

  • Before sending text: The task will delay sending text until the default prompt appears.

  • After sending text: The task will wait for the default prompt after sending text. The following step will not execute until the appearance of the default prompt.

  • Before and after sending text: The task will delay sending text until the default prompt appears and wait again for the default prompt after sending text.

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 allows you to 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 and Functions

All text fields allow the use of expressions such as variables, functions or AutoMate extended functions, which can be entered by surrounding the expression in percentage signs (example: %FileDateTime(myVar)% or %myVar%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on function

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 - This sample step sends the following text "This is the text to send" to terminal session "MyTermSess." It is set to wait before and after the default prompt appears.

 

<AMSENDTERMTEXT SESSION="MyTermSess" WAITFORDEFAULTPROMPT="BOTH">This is the text to send.</AMSENDTERMTEXT>

 

 

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