The Script() action runs a child process of the emulator, which can supply actions for the emulator to execute. (This is in contrast to the Source() action, which reads a file containing a list of actions, and executes them one after the other.)
The syntax for Script() is as follows:
- [option...] script-name [argument...]
- All Script() options begin with a
- The name (full pathname if necessary) of an executable program to run.
- The balance of the parameters as passed as command-line arguments to the program.
- Asynchronous script. The Script() action returns immediately, without waiting for the program to exit. Any output from the program will be reported with a pop-up, unless -nostdoutredirect is also given.
- (c3270 and wc3270 only) Run the script on the terminal or window where the emulator is running, allowing it to access standard input and standard output. New in 4.2
- Do not disable the keyboard while the script is running. (Normally the keyboard is disabled during script execution, so user actions do not interfere with the operation of the script.)
- Do not redirect standard output and standard error from the script. Without this option, the result of the Script() action is the output from the program.
- If a socket is used with the s3270 protocol, the emulator will accept just a single connection and then close the listener.
- (Windows only) Share the console between the emulator and the child process. Without this option, the child process is started detached, with no console. New in 4.0
Script() blocks until the program exits. This can be overridden with the -async option.
Communication between the script and emulator
There are three different ways that a child script can communicate with the emulator.
On POSIX, pipes will be created for communicating with the emulator via the s3270 protocol.
The file descriptor number for the pipe for passing commands to the emulator is passed to the program via the
X3270INPUT environment variable.
The file descriptor number for the pipe for returning results back to the emulator is passed to the program via the
X3270OUTPUT environment variable.
Script() returns the output of the program. This can be overridden with the -nostdoutredirect option. Script() will fail if the program exits with non-zero status.
Run a typical script, giving it two command-line parameters.