Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > c9de6c87acad32ea83dbcfbce3766ca1 > files > 72

x3270-3.2.19-2mdk.ppc.rpm

<html>
<head>
<title>x3270-script Manual Page</title>
<link HREF="http://www.w3.org/StyleSheets/Core/Steely" TYPE="text/css" REL="stylesheet">
</head>
<body>
<h1>x3270-script Manual Page</h1>
<h2>Contents</h2>
<blockquote>
<a HREF="#Name">Name</a><br>
<a HREF="#Synopsis">Synopsis</a><br>
<a HREF="#Description">Description</a><br>
<a HREF="#Status-Format">Status Format</a><br>
<a HREF="#Differences">Differences</a><br>
<a HREF="#Script-Specific-Actions">Script-Specific Actions</a><br>
<a HREF="#File-Transfer">File Transfer</a><br>
<a HREF="#See-Also">See Also</a><br>
<a HREF="#Version">Version</a><br>
</blockquote>
<a NAME="Name"></a><h2>Name</h2>
Scripting Facilities for x3270, s3270 and c3270
<a NAME="Synopsis"></a><h2>Synopsis</h2>
<b>x3270</b> <b>-script</b> [ <i>x3270-options</i> ]
<br>
<b>s3270</b> [ <i>x3270-options</i> ]
<br>
<b>Script</b> ( <i>command</i> [ ,<i>arg</i>... ] )
<a NAME="Description"></a><h2>Description</h2>
The <b>x3270</b> scripting facilities allow the interactive 3270 emulators
<b>x3270</b> and <b>c3270</b> to be operated under the control of another
program, and form the basis for the script-only emulator <b>s3270</b>.
<p>
There are two basic scripting methods.
The first is the <b>peer script</b> facility, invoked by the <b>x3270</b>
<b>-script</b> switch, and the default mode for <b>s3270</b>.
This runs <b>x3270</b> or <b>s3270</b> as a child of another process.
Typically this would be a script using
<i>expect</i>(1), <i>perl</i>(1),
or the co-process facility of the Korn Shell
<i>ksh</i>(1).
Inthis mode, the emulator process looks for commands on its standard input,
and places the responses on standard output and standard error output.
<p>
The second method is the <b>child script</b>
facility, invoked by the <b>Script</b> action in <b>x3270</b>, <b>c3270</b>,
or <b>s3270</b>.
This runs a script as a child process of the emulator.
The child has access to pipes connected to the emulator; the emulator
look for commands on one pipe, and places the responses on the other.
(The file descriptor of the pipe for commands to the emulator
is passed in the environment variable X3270INPUT; the file descriptor
of the pipe for responses from the emulator is passed in the environment
variable X3270OUTPUT.)
<p>
It is possible to mix the two methods.
A script can invoke another script with the <b>Script</b> action, and
may also be implicitly nested when a script invokes the
<b>Connect</b>
action, and the
<b>ibm_hosts</b>
file specifies a login script for that host name.
<p>
Commands are emulator <i>actions</i>; the syntax is the same as for the
right-hand side of an Xt translation table entry (an <b>x3270</b> or
<b>c3270</b> keymap).
Unlike translation tables, action names are case-insensitive, can be
uniquely abbreviated, and the parentheses may be omitted if there are
no parameters.
<p>
Any emulator action may be specified.
Several specific actions have been defined for use by scripts, and the behavior
of certain other actions (and of the emulators in general) is different when
an action is initiated by a script.
<p>
Some actions generate output; some may delay completion until the certain
external events occur, such as the host unlocking the keyboard.
The completion of every command is marked by a two-line message.
The first line is the current status of the emulator, documented below.
If the command is successful, the second line is the string "ok"; otherwise it
is the string "error".
<a NAME="Status-Format"></a><h2>Status Format</h2>
The status message consists of 11 blank-separated fields:
<dl><dt>1 Keyboard State</dt><dd>
If the keyboard is unlocked, the letter
<b>U</b>.
If the keyboard is locked waiting for a response from the host, or if not
connected to a host, the letter
<b>L</b>.
If the keyboard is locked because of an operator error (field overflow,
protected field, etc.), the letter
<b>E</b>.
<dt>2 Screen Formatting</dt><dd>
If the screen is formatted, the letter
<b>F</b>.
If unformatted or in <font size=-1>NVT</font> mode, the letter <b>U</b>.
<dt>3 Field Protection</dt><dd>
If the field containing the cursor is protected, the letter
<b>P</b>.
If unprotected or unformatted, the letter
<b>U</b>.
<dt>4 Connection State</dt><dd>
If connected to a host, the string
<b>C(</b><i>hostname</i><b>)</b>.
Otherwise, the letter
<b>N</b>.
<dt>5 Emulator Mode</dt><dd>
If connected in 3270 mode, the letter
<b>I</b>.
If connected in <font size=-1>NVT</font> line mode, the letter
<b>L</b>.
If connected in <font size=-1>NVT</font> character mode, the letter
<b>C</b>.
If not connected, the letter
<b>N</b>.
<dt>6 Model Number (2-5)</dt><dd>
<dt>7 Number of Rows</dt><dd>
The current number of rows defined on the screen.
The host can request that the emulator
use a 24x80 screen, so this number may be smaller than the maximum number of
rows possible with the current model.
<dt>8 Number of Columns</dt><dd>
The current number of columns defined on the screen, subject to the same
difference for rows, above.
<dt>9 Cursor Row</dt><dd>
The current cursor row (zero-origin).
<dt>10 Cursor Column</dt><dd>
The current cursor column (zero-origin).
<dt>11 Window ID</dt><dd>
The X window identifier for the main
<b>x3270</b>
window, in hexadecimal preceded by
<b>0x</b>.
For
<b>s3270</b> and <b>c3270</b>,
this is zero.
</dl>
<a NAME="Differences"></a><h2>Differences</h2>
When an action is initiated by a script, the emulators
behave in several different ways:
<p>
If an error occurs in processing an ection, the usual pop-up window does not
appear.
Instead, the text is written to standard error output.
<p>
If end-of-file is detected on standard input, the emulator exits.
(A script can exit without killing the emulator
by using the <b>CloseScript</b> action, below.)
Note that this applies to peer scripts only; end-of-file on the pipe
connected to a child script simply causes the pipes to be closed and
the
<b>Script</b>
action to complete.
<p>
The <b>Quit</b> action always causes the emulator to exit.
(When called from the keyboard, it will exit only if not connected to a host.)
<p>
The
<b>Clear</b>,
<b>Enter</b>,
<b>PF</b>,
and
<b>PA</b>
actions will not complete until the host
unlocks the keyboard.
If the parameter to a
<b>String</b>
action includes a code for one these actions,
it will also wait for the keyboard to unlock before completing.
Similarly, the
<b>Script</b>
action does not complete until end-of-file is
detected on the pipe or the
<b>CloseScript</b>
action is called by the child
process.
<a NAME="Script-Specific-Actions"></a><h2>Script-Specific Actions</h2>
The following actions have been defined or modified for use with scripts.
(Note that unlike the display on the status line,
<i>row</i>
and
<i>col</i>
coordinates used in these actions use [0,0] as their origin, not [1,1]).
<dl><dt><b>AnsiText</b></dt><dd>
Outputs whatever data that has been output by the host in
<font size=-1>NVT</font> mode
since the last time that
<b>AnsiText</b>
was called.
The data is preceded by the string "data:&nbsp;", and has had all control characters
expanded into C backslash sequences.
<p>
This is a convenient way to capture
<font size=-1>NVT</font>
mode output in a synchronous manner without trying to decode the screen
contents.
<dt><b>Ascii</b>(<i>row</i>,<i>col</i>,<i>rows</i>,<i>cols</i>)</dt><dd>
<dt><b>Ascii</b>(<i>row</i>,<i>col</i>,<i>length</i>)</dt><dd>
<dt><b>Ascii</b>(<i>length</i>)</dt><dd>
<dt><b>Ascii</b></dt><dd>
Outputs an <font size=-1>ASCII</font> text representation of the screen contents.
Each line is preceded by the string "data:&nbsp;", and there are no control
characters.
<p>
If four parameters are given, a rectangular region of the screen is output.
<p>
If three parameters are given,
<i>length</i>
characters are output, starting at the specified row and column.
<p>
If only the
<i>length</i>
parameter is given, that many characters are output, starting at the cursor
position.
<p>
If no parameters are given, the entire screen is output.
<dt><b>AsciiField</b></dt><dd>
Outputs an <font size=-1>ASCII</font> text representation of the field containing the cursor.
The text is preceded by the string "data:&nbsp;".
<dt><b>Connect</b>(<i>hostname</i>)</dt><dd>
Connects to a host.
The command does not return until the emulator
is successfully connected in the proper mode, or the connection fails.
<dt><b>CloseScript</b>(<i>status</i>)</dt><dd>
Causes the emulator to stop reading commands from the script.
This is useful to allow a peer script to exit, with the emulator
proceeding interactively.
(Without this command, the emulator
would exit when it detected end-of-file on standard input.)
If the script was invoked by the
<b>Script</b>
action, the optional
<i>status</i>
is used as the return status of
<b>Script</b>;
if nonzero,
<b>Script</b>
will complete with an error, and if this script was invoked as part of
login through the
<b>ibm_hosts</b>
file, the connection will be broken.
<dt><b>ContinueScript</b>(<i>param</i>)</dt><dd>
Allows a script that is waiting in a
<b>PauseScript</b>
action, below, to continue.
The
<i>param</i>
given is output by the
<b>PauseScript</b>
action.
<dt><b>Disconnect</b></dt><dd>
Disconnects from the host.
<dt><b>Ebcdic</b>(<i>row</i>,<i>col</i>,<i>rows</i>,<i>cols</i>)</dt><dd>
<dt><b>Ebcdic</b>(<i>row</i>,<i>col</i>,<i>length</i>)</dt><dd>
<dt><b>Ebcdic</b>(<i>length</i>)</dt><dd>
<dt><b>Ebcdic</b></dt><dd>
The same function as
<b>Ascii</b>
above, except that rather than generating
<font size=-1>ASCII</font>
text, each character is output as a hexadecimal
<font size=-1>EBCDIC</font>
code, preceded by
<b>0x</b>.
<dt><b>EbcdicField</b></dt><dd>
The same function as
<b>AsciiField</b>
above, except that it generates hexadecimal
<font size=-1>EBCDIC</font>
codes.
<dt><b>Info</b>(<i>message</i>)</dt><dd>
Pops up an informational message.
<dt><b>Expect</b>(<i>text</i>[,<i>timeout</i>])</dt><dd>
Pauses the script until the specified
<i>text</i>
appears in the data stream from the host, or the specified
<i>timeout</i>
(in seconds) expires.
If no
<i>timeout</i>
is specified, the default is 30 seconds.
<i>Text</i>
can contain standard C-language escape (backslash) sequences.
No wild-card characters or pattern anchor characters are understood.
<b>Expect</b>
is valid only in
<font size=-1>NVT</font>
mode.
<dt><b>MoveCursor</b>(<i>row</i>,<i>col</i>)</dt><dd>
Moves the cursor to the specified coordinates.
<dt><b>PauseScript</b></dt><dd>
Stops a script until the
<b>ContinueScript</b>
action, above, is executed.
This allows a script to wait for user input and continue.
Outputs the single parameter to
<b>ContinueScript</b>.
<dt><b>Snap</b></dt><dd>
Equivalent to <b>Snap</b>(<b>Save</b>) (see <a HREF="#save">below</a>).
<dt><b>Snap</b>(<b>Ascii</b>,...)</dt><dd>
Performs the <b>Ascii</b> action on the saved screen image.
<dt><b>Snap</b>(<b>Cols</b>)</dt><dd>
Returns the number of columns in the saved screen image.
<dt><b>Snap</b>(<b>Ebcdic</b>,...)</dt><dd>
Performs the <b>Ebcdic</b> action on the saved screen image.
<dt><b>Snap</b>(<b>Rows</b>)</dt><dd>
Returns the number of rows in the saved screen image.
<a NAME="save"></a><dt><b>Snap</b>(<b>Save</b>)</dt><dd>
Saves a copy of the screen image and status in a temporary buffer.
This copy can be queried with other
<b>Snap</b>
actions to allow a script to examine a consistent screen image, even when the
host may be changing the image (or even the screen dimensions) dynamically.
<dt><b>Snap</b>(<b>Status</b>)</dt><dd>
Returns the status line from when the screen was last saved.
<dt><b>Snap</b>(<b>Wait</b>[,<i>timeout</i>],<b>Output</b>)</dt><dd>
Pauses the script until the host sends further output, then updates the snap
buffer with the new screen contents.
Used when the host unlocks the keyboard (allowing the script to proceed after
an
<b>Enter</b>,
<b>PF</b>
or
<b>PA</b>
action), but has not finished updating the screen.
This action is usually invoked in a loop that uses the
<b>Snap</b>(<b>Ascii</b>)
or
<b>Snap</b>(<b>Ebcdic</b>)
action to scan the screen for some pattern that indicates that the host has
fully processed the last command.
<p>
The optional <i>timeout</i> parameter specifies a number of seconds to wait
before failing the <b>Snap</b> action.  The default is to wait forever.
<dt><b>Transfer</b>(<i>keyword</i>=<i>value</i>,...)</dt><dd>
Invokes IND$FILE file transfer.
See <a HREF="#File-Transfer"><font size=-1>FILE TRANSFER</font></a> below.
<dt><b>Wait</b>([<i>timeout</i>,] <b>3270Mode</b>)</dt><dd>
Used when communicating with a host that switches between
<font size=-1>NVT</font> mode and 3270 mode.
Pauses the script or macro until the host negotiates 3270 mode, then waits for
a formatted screen as above.
<p>
The optional <i>timeout</i> parameter specifies a number of seconds to wait
before failing the <b>Wait</b> action.  The default is to wait forever.
<p>
For backwards compatibility,
<b>Wait(3270)</b>
is equivalent to
<b>Wait</b>(<b>3270Mode</b>)
<dt><b>Wait</b>([<i>timeout</i>,] <b>Disconnect</b>)</dt><dd>
Pauses the script until the host disconnects.
Often used to after sending a
<i>logoff</i>
command to a <font size=-1>VM/CMS</font> host, to ensure that the session is not unintentionally
set to
<b>disconnected</b>
state.
<p>
The optional <i>timeout</i> parameter specifies a number of seconds to wait
before failing the <b>Wait</b> action.  The default is to wait forever.
<dt><b>Wait</b>([<i>timeout</i>,] <b>InputField</b>)</dt><dd>
A useful utility for use at the beginning of scripts and after the
<b>Connect</b> action.
In 3270 mode, waits until the screen is formatted, and the host has positioned
the cursor on a modifiable field.
In <font size=-1>NVT</font> mode, waits until the host sends at least one byte of data.
<p>
The optional <i>timeout</i> parameter specifies a number of seconds to wait
before failing the <b>Wait</b> action.  The default is to wait forever.
<p>
For backwards compatibility,
<b>Wait</b>
is equivalent to
<b>Wait</b>(<b>InputField</b>).
<dt><b>Wait</b>([<i>timeout</i>,] <b>NVTMode</b>)</dt><dd>
Used when communicating with a host that switches between 3270 mode and
<font size=-1>NVT</font> mode.
Pauses the script or macro until the host negotiates <font size=-1>NVT</font>
mode, then waits for
a byte from the host as above.
<p>
The optional <i>timeout</i> parameter specifies a number of seconds to wait
before failing the <b>Wait</b> action.  The default is to wait forever.
<p>
For backwards compatibility,
<b>Wait</b>(<b>ansi</b>)
is equivalent to
<b>Wait</b>(<b>NVTMode</b>).
<dt><b>Wait</b>([<i>timeout</i>,] <b>Output</b>)</dt><dd>
Pauses the script until the host sends further output.
Used when the host unlocks the keyboard (allowing the script to proceed after
an
<b>Enter</b>,
<b>PF</b>
or
<b>PA</b>
action), but has not finished updating the screen.
This action is usually invoked in a loop that uses the
<b>Ascii</b>
or
<b>Ebcdic</b>
action to scan the screen for some pattern that indicates that the host has
fully processed the last command.
<p>
The optional <i>timeout</i> parameter specifies a number of seconds to wait
before failing the <b>Wait</b> action.  The default is to wait forever.
</dl>
<a NAME="File-Transfer"></a><h2>File Transfer</h2>
The <b>XX_LA()Transfer</b> action implements <b>IND$FILE</b> file transfer.
This action requires that the <b>IND$FILE</b>
program be installed on the <font size=-1>IBM</font> host, and that the 3270 cursor
be located in a field that will accept a <font size=-1>TSO</font> or <font size=-1>VM/CMS</font> command.
<p>
Because of the complexity and number of options for file transfer, the
parameters to the <b>XX_LA()Transfer</b> action take the unique form
of <i>option</i>=<i>value</i>, and can appear in any order.
The options are:
<p>
<table BORDER cols=4 width="75%">
<tr><td >Option</td>	<td >Required?</td>	<td >Default</td>	<td >Other Values</td></tr>

<tr><td >Direction</td>	<td >No</td>	<td >send</td>	<td >receive</td></tr>
<tr><td >HostFile</td>	<td >Yes</td>	<td >&nbsp;</td>	<td >&nbsp;</td></tr>
<tr><td >LocalFile</td>	<td >Yes</td>	<td >&nbsp;</td>	<td >&nbsp;</td></tr>
<tr><td >Host</td>	<td >No</td>	<td >tso</td>	<td >vm</td></tr>
<tr><td >Mode</td>	<td >No</td>	<td >ascii</td>	<td >binary</td></tr>
<tr><td >Cr</td>	<td >No</td>	<td >remove</td>	<td >add, keep</td></tr>
<tr><td >Exist</td>	<td >No</td>	<td >keep</td>	<td >replace, append</td></tr>
<tr><td >Recfm</td>	<td >No</td>	<td >&nbsp;</td>	<td >fixed, variable, undefined</td></tr>
<tr><td >Lrecl</td>	<td >No</td>	<td >&nbsp;</td>	<td >&nbsp;</td></tr>
<tr><td >Blksize</td>	<td >No</td>	<td >&nbsp;</td>	<td >&nbsp;</td></tr>
<tr><td >Allocation</td>	<td >No</td>	<td >&nbsp;</td>	<td >tracks, cylinders, avblock</td></tr>
<tr><td >PrimarySpace</td>	<td >No</td>	<td >&nbsp;</td>	<td >&nbsp;</td></tr>
<tr><td >SecondarySpace</td>	<td >No</td>	<td >&nbsp;</td>	<td >&nbsp;</td></tr>
</table>
<p>
The option details are as follows.
<dl><dt><b>Direction</b></dt><dd>
<b>send</b> (the default) to send a file to the host,
<b>receive</b> to receive a file from the host.
<dt><b>HostFile</b></dt><dd>
The name of the file on the host.
<dt><b>LocalFile</b></dt><dd>
The name of the file on the local workstation.
<dt><b>Host</b></dt><dd>
The type of host (which dictates the form of the <b>IND$FILE</b> command):
<b>tso</b> (the default) or <b>vm</b>.
<dt><b>Mode</b></dt><dd>
Use <b>ascii</b> (the default) for a text file, which will be translated
between <font size=-1>EBCDIC</font> and <font size=-1>ASCII</font> as necessary.
Use <b>binary</b> for non-text files.
<dt><b>Cr</b></dt><dd>
Controls how <b>Newline</b> characters are handled when transferring
<b>Mode=ascii</b> files.
<b>remove</b> (the default) strips <b>Newline</b> characters in local files
before transferring them to the host.
<b>add</b> adds <b>Newline</b> characters to each host file record before
transferring it to the local workstation.
<b>keep</b> preserves <b>Newline</b> characters when transferring a local file
to the host.
<dt><b>Exist</b></dt><dd>
Controls what happens when the destination file already exists.
<b>keep</b> (the default) preserves the file, causing the
<b>XX_LA()Transfer</b> action to fail.
<b>replace</b> overwrites the destination file with the source file.
<b>append</b> appends the source file to the destination file.
<dt><b>Recfm</b></dt><dd>
Controls the record format of files created on the host.
<b>fixed</b> creates a file with fixed-length records.
<b>variable</b> creates a file with variable-length records.
<b>undefined</b> creates a file with undefined-length records (<font size=-1>TSO</font> hosts only).
The <b>Lrecl</b> option controls the record length or maximum record length for
<b>Recfm=fixed</b> and <b>Recfm=variable</b> files, respectively.
<dt><b>Lrecl</b></dt><dd>
Specifies the record length (or maximum record length) for files created on
the host.
<dt><b>Blksize</b></dt><dd>
Specifies the block size for files created on the host.  (<font size=-1>TSO</font> hosts only.)
<dt><b>Allocation</b></dt><dd>
Specifies the units for the <font size=-1>TSO</font> host <b>PrimarySpace</b> and
<b>SecondarySpace</b> options: <b>tracks</b>, <b>cylinders</b> or
<b>avblock</b>.
<dt><b>PrimarySpace</b></dt><dd>
Primary allocation for a file created on a <font size=-1>TSO</font> host.
The units are given by the <b>Allocation</b> option.
<dt><b>SecondarySpace</b></dt><dd>
Secondary allocation for a file created on a <font size=-1>TSO</font> host.
The units are given by the <b>Allocation</b> option.
</dl>
<a NAME="See-Also"></a><h2>See Also</h2>
expect(1)
<br>
ksh(1)
<br>
<a HREF="x3270-man.html">x3270(1)</a>
<br>
<a HREF="c3270-man.html">c3270(1)</a>
<br>
<a HREF="s3270-man.html">s3270(1)</a>
<a NAME="Version"></a><h2>Version</h2>
Version 3.2.19
<hr>
<address>
This HTML document and the accompanying troff document were generated with
a set of write-only <b>m4</b> macros and the powerful <b>vi</b> editor.
<br>Last modified 01 May 2002.
</address>
</body>
</html>