Terminal - Send text

Declaration

<AMSENDTERMTEXT SESSION="texts" WAITFORDEFAULTPROMPT="Text (options)">"Text"</AMSENDTERMTEXT>

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.

Related Topics  

Parameters

General

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

  1. WAITFORDEFAULTPROMPT="before"

  2. WAITFORDEFAULTPROMPT="after"

  3. WAITFORDEFAULTPROMPT="both"

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

Error Causes

On Error

Additional Notes

Terminal Function Keys

Function keys on a terminal may either generate short fixed sequences of characters or the characters they generate may be configured by sending special character sequences to the terminal. On a standard computer keyboard, the function keys may generate a fixed, single byte code, outside the normal ASCII range, which is translated into some other configurable sequence by the keyboard device driver or interpreted directly by the application. The following list contains function keys that this activity can use to send to the terminal by simply enclosing them with with {} (i.e. {ENTER})

Function of Key

Key

Backspace

BS, BKSP, BACKSPACE

Nul

NUL

Start of heading

SOH

Start text character

STX

End of text

ETX

End of transmission

EOT

Enquire

ENQ

Acknowledge

ACK

Ring terminal bell (beep)

BEL

Backspace

BS

Horizontal tab

HT

Next line

NL

Vertical tabulation

VT

Form feed

FF

Carriage return

CR

Shift out

SO

Shift in

SI

Data link escape

DLE

Device control 1

DC1

Device control 2

DC2

Device control 3

DC3

Device control 4

DC4

Negative acknowledge

NAK

Synchronous idle

SYN

End transmission block

ETB

Cancel

CAN

End of medium

EM

Substitute

SUB

Escape

ESC

File separator

FS

Group separator

GS

Record separator

RS

Unit separator

US

Delete

DEL, DELETE

Down arrow key

DOWN

End key

END

Space key

SPACE

Enter key

ENTER

Help

HELP

Home key

HOME

Insert key

INSERT

Left arrow  key

LEFT

Numlock key

NUMLOCK

Page down key

PGDN

Page up key

PGUP

Print screen key

PRTSC

Right arrow key

RIGHT

Tab key

TAB

Up arrow key

UP

Input function keys

F1 to F24

0 to 9 keys

NUMPAD0 to NUMPAD9

* key

NUMPAD*

+ key

NUMPAD+

Separator

NUMPADSEP

- key

NUMPAD-

. key

NUMPAD.

/ key

NUMPAD/

TN Terminal keys

The following table lists extra keys for TN Terminals

Function of Key

Key

Page left

PGLEFT

Page right

PGRIGHT

Attention

TN_KEY_ATTN

Backspace

TN_KEY_BACKSPACE

Back tab

TN_KEY_BACKTAB

Clear

TN_KEY_CLEAR

Select cursor

TN_KEY_CURSORSEL

Duplicate

TN_KEY_DUP

Enter

TN_KEY_ENTER

Erase a field to end of field

TN_KEY_ERASEEOF

Erase input

TN_KEY_ERASEINPUT

Mark

TN_KEY_MARK

New line

TN_KEY_NEWLINE

Program attention 1

TN_KEY_PA1

Program attention 2

TN_KEY_PA2

Program attention 3

TN_KEY_PA3

Reset

TN_KEY_RESET

SysRq key

TN_KEY_SYSREQ

Tab forward

TN_KEY_TABFORWARD

No op mode

TN_KEY_NOOP

Examples

NOTE: The sample AML code below can be copied and pasted directly into the Steps panel 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:

This sample task uses an assortment of terminal activities to automate a terminal logon process. Examining the step parameters and properties of this task may assist you in creating your own terminal emulation task.

<AMVARIABLE NAME="theUsername" VALUE="terminalUser" />

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

<AMTERMINAL HOST="linux.networkautomation.com" SESSION="TerminalSession1" SHOWTERMINALWINDOW="YES" EMULATION="vt220" />

<AMTERMINAL ACTIVITY="waitfor" SESSION="TerminalSession1" TEXT="login:" />

<AMTERMINAL ACTIVITY="sendtext" SESSION="TerminalSession1" TEXT="%theUsername%{ENTER}" />

<AMSHOWDIALOG MESSAGE="OK to proceed?" />

<AMTERMINAL ACTIVITY="waitfor" SESSION="TerminalSession1" TEXT="Password:" />

<AMTERMINAL ACTIVITY="sendtext" SESSION="TerminalSession1" TEXT="%thePassword%{ENTER}" />

<AMSHOWDIALOG MESSAGE="OK to proceed?" />

<AMTERMINAL ACTIVITY="disconnect" SESSION="TerminalSession1" />