The Interpreter script works in conjunction with the SCPTelnet plug-in, and contains syntax that tells the Telnet plug-in how to add, modify, and delete user accounts on various server environments.
The function of the Interpreter is to interpret an ASCII formatted script file, and interact with a host machine accordingly. The script files contains "instructions" to the Interpreter for adding, modifying, or deleting account information from a remote host. The Interpreter, in turn, provides this information to the SCPTelnet program. The advantage of this methodology is that the SCPTelnet program can communicate with many different types of remote hosts, since the script file can be easily modified and customized.
In addition to sending and receiving messages from a remote host, the Interpreter also outputs all the remote host’s messages to a log file.
Since both the script file and log file names are configured as server-specific parameters, the SCPTelnet program has the ability to interact with host servers under almost any platform, as long as the servers are able to use the Telnet protocol for communication.
The following sections describe each aspect of the Interpreter script in more detail:
Overview of the Interpreter Script
Before the SCPTelnet program can initialize, it needs a set of pre-configured parameters, which are passed to it from the Server Control module. These parameters are used in conjunction with the script file by the Interpreter program.
Telnet Interpreter Script Required Parameters
The basic structure of the Interpreters script is as follows:
Interpreter Script Structure
As is evident, the basic structure of the file is much like a normal programming module. All the scripts are contained within the //SCRIPT-BEGIN and the //SCRIPT-END statements, and within either the ":HOST-SIGNIN:" block or one of the service label blocks. In the section below, each part of the script file is explained in more detail.
Script Parts
The following section describes details about the script syntax. The first section will describe some parameters and characters recognized by the Interpreter program. The second section describes the syntax of specific statements.
Special Handling For Suspend/Unsuspend
The script should contain some required labels in order to allow the Interpreter to properly perform some basic functions:
|
Label Name |
Function description |
|
:HOST-SIGNIN: |
Called first to log on to the Host for telnet session |
|
:OPEN: |
Performs an open account request |
|
:MODIFY: |
Performs a modify account request |
|
:SUSPEND: |
Performs a suspend account request |
|
:UNSUSPEND: |
Performs an unsuspend account request |
|
:CLOSE: |
Performs a close account request |
All script statements should begin with a keyword. The following is a list of recognized keywords:
Keyword |
Definitions |
|
CASE |
Indicates the start of the Case block See Example. |
|
ENDCASE |
Indicates the end of the Case block. See Example. |
|
WAIT |
Indicates the start of the Wait Loop. See Example. |
|
ENDWAIT |
Indicates the end of the Wait Loop. See Example. |
|
HOSTMSG |
Specifies the action to be taken when certain host message is received. See Example. |
|
TIMEOUT |
Specifies the action to be taken if no message is received within time limit. See Example. |
|
EXITLOOP |
Tell interpreter to jump to the statement following the nearest ENDWAIT. See Example. |
|
GOTO |
Execution jumps to the specified label. See Example. |
|
SEND |
Specifies what to send to the host |
|
ERRMSG |
Returns error message back to calling procedure, the server control module. See Example. |
|
SVC-EXECUTED |
Indicates service (or request) is executed successfully. See Example. See Example. |
|
DEFINE |
Used to define constants. See Example. |
|
//SCRIPT-BEGIN |
Indicates the beginning of the script. |
|
//SCRIPT-END |
Indicates the end of the script |
|
[+CRLF] |
Used to send out CRLF to the host. See Example. |
Certain characters may also be used within the script. The following is a list of characters that the Interpreter recognizes.
Characters |
Meaning |
Examples |
|
< |
Left delimiter indicates the start of a command string to be sent out to the host |
<su> |
|
> |
Right delimiter indicates the end of the command string to be sent out to the host |
|
|
[ |
Left delimiter indicates the start of the parameter name |
[Password] |
|
] |
Right delimiter indicates the end of the parameter name |
|
|
== |
Assigns string on the right to the string (constant) on the left |
DEFINE %User Home Path% == /home/ |
|
% |
Delimiter indicates the begin and the end of the constant string |
DEFINE %User Home Path% |
|
, |
(Comma) delimiter separates two statements on the same line |
TIMEOUT, GOTO HOST-LOGIN-TIMEOUT |
|
: |
Delimiter indicates both the start and the end of a label string |
:HOST-SIGNIN: |
|
’ |
(Single quote) delimiter indicates both the start and the end of a string from a host or a string to be returned back to the calling procedure as an error message |
HOSTMSG 'ogin' |
|
_ |
Character that indicates the continuation of a statement into another line. |
See sample scripts |
|
~ |
Special character that indicates that a space should not be inserted (NOTE: This character is only recognized in the SEND statement) |
See sample scripts |
|
= |
Character used for comparison in a CASE statement |
CASE [Account Name] = ‘John Doe’ |
The following section describes the statements that are recognized by the Interpreter program and the syntax of each.
|
Statement |
Description |
Examples |
|
CASE/ENDCASE |
Performs the enclosed statements based on a conditional value. |
Example 1: CASE [Parameter A] Statement 1 Statement 2 ENDCASE
Example 2: CASE [Parameter A] = ‘string’ Statement 1 Statement 2 ENDCASE
|
|
WAIT/ENDWAIT |
Contains one or more HOSTMSG statements and only one TIMEOUT statement. The Interpreter waits for a default amount of time (120 seconds), or for an amount of time specified in the WAIT statement for messages from the HOST. String values contained in the HOST message are compared against the string value in the WAIT statement until a match is made. Once a match is made, the script in the HOSTMSG statement is performed. If no match is made within the time limit, the TIMEOUT statement is executed.
|
Example 1: WAIT HOSTMSG ‘string’ Statement TIMEOUT, Statement ENDWAIT
Example 2: WAIT HOSTMSG ‘string’ Statement HOSTMSG ‘string’ Statement TIMEOUT, Statement ENDWAIT
|
|
HOSTMSG |
Enables the user to respond to different host messages. Appear within WAIT/ENDWAIT loops. The HOSTMSG keyword is followed by a string of text surrounded by " ‘ ". One or more script statements follow the text string. Script statements are separated by ",".
|
HOSTMSG ‘message1’, SEND <useradd>,EXITLOOP HOSTMSG ‘message2’,SEND <userdel>, GOTO label HOSTMSG ‘error from host’, ERRMSG ‘error message’ |
|
TIMEOUT |
Appear inside WAIT/ENDWAIT loops. Enables the user to specify an action to be taken in case of a timeout. TIMEOUT statements can contain only one script statement.
|
TIMEOUT, ERRMSG ‘error message – timeout’ |
|
EXITLOOP |
Appears within the WAIT/ENDWAIT loop, and provides a way to directly exit the loop.
|
HOSTMSG 'string', SEND [Parameter], EXITLOOP |
|
GOTO |
Jumps to the service label specified in the string after the GOTO keyword. |
HOSTMSG ‘sample’, GOTO Label-1
(Label-1 should exist elsewhere in the script).
|
|
SEND |
Sends commands and messages to the HOST. The SEND statement may contain either a Command String or a Parameter. Command strings, enclosed in "<>" are sent directly to the HOST. More than one command can be specified. Parameter strings, enclosed in "[]" are looked up from the calling procedure (Server Control) for the values, which are then extracted and sent to the HOST. More than one parameter can be specified. The character "~" can be place between parameters to eliminate a space. Otherwise a space is always inserted between parameter names. |
SEND <useradd> [parameter1][parameter2] SEND <useradd> [parameter1]<-d>~[parameter2] SEND <exit> SEND <parameter1> SEND [CRLF] *
* [CRLF] is a special parameter that tells the Interpreter to send out a carriage return. |
|
ERRMSG |
Returns error messages back to the calling procedure (Server Control). The ERRMSG is followed by a string contained in " ‘ ". This string is returned to the calling procedure, and the script is terminated. |
ERRMSG ‘error message’ |
|
SVC-EXECUTED |
Indicates that a service is executed successfully. When this statement is reached, the Interpreter returns a message of success to the calling procedure (Server Control) and exits the script. |
|
|
DEFINE |
Allows users to define constants within the script file. The DEFINE keyword should be followed by a string enclosed in "%", a constant name, then a "==" followed by another string value. The string on the left of the "==" is assigned the value on the left of the "==". |
DEFINE %command 1% == useradd . . SEND %command 1%
|
Because different systems usually have different special handling procedures for the suspend and un-suspend actions, these can be especially difficult. The Interpreter tries to eliminate this problem by using it’s own special handling procedures.
The user should specify a modify password command in both the SUSPEND and UNSUSPEND service sections of the script. When the user passes in the Login and Password to the SCPTelnet program for the SUSPEND action, the Interpreter will automatically adjust the password to something else. This causes the customer to become unable to log in. In un-suspending the account, the user passes in the Login with the original password and the Interpreter will change the password back to the original one on the host system. (See the Appendix – LINUX sample script for a example of the suspend/un-suspend actions).