Scripting for the GroupWise Async Gateway

A script can be included with the Async Gateway. This feature extends many aspects of the gateway. To familiarize you with this functionality, some instances where scripting is useful are included in this section.

Scripting can be used to configure the Async gateway to perform X.25 network logins in order to utilize third-party X.25 networks for cheaper international connections. The gateway can also be configured to attempt a less expensive route and then fall back to more expensive routes if the call cannot be completed through a cheaper route.

Long phone numbers (for example, strings that include credit card numbers) can now be dialed via a script.

Scripts can be used to handle any pre-call dialing necessary to satisfy some PBX environments.


Script File Details

A script file is a sequence of statements and possibly comments that the gateway automatically detects and uses.

A default script can be created to govern all connections. Link-specific scripts can also be generated. If both a default script and a link-specific script exist, the link-specific script overrides the default script for the specific link. Consequently, it is possible to create a default script to handle most links and then create link-specific scripts for any exceptions.

The term "link" refers to a domain connection defined within ConsoleOne®. Subdirectories for each link can be found in the \domain\wpgate\gateway\gwout\.directory Wherever possible, the gateway uses the connection name (defined within ConsoleOne) as the directory name. However, if a directory with that name already exists, the gateway creates a unique directory name.

Default scripts are named default.scr and are placed in the \domain\wpgate\gateway\gwout\ directory Link-specific scripts are named link.scr and are placed in the individual \domain\wpgate\gateway\gwout\link_id link subdirectories:

HINT:  The Domain Connections panel in ConsoleOne contains a field for the Remote Phone Number. This field represents the phone number you dial to complete the domain connection. If this field is empty, the gateway does not dial. If you choose to embed dialing instructions within a script (to avoid putting the phone number in the Remote Phone Number field), it is sufficient to place a space in that field.


Scripting Language

The script file consists of a sequence of statements and possible comments. Comments start with a pound (#) character and run to the end of the line. The following is the list of statements that can be used.


SEND string

Sends the string to the connection.


SETDTR

Raises both the Data Terminal Ready (DTR) and Request To Send (RTS) signals.


SETRTS

Lowers the Data Terminal Ready (DTR) signal and raises the Request To Send (RTS) signal.


CLRDTR

Lowers the Data Terminal Ready (DTR) and Request To Send (RTS) signals.


CLRRTS

Raises the Data Terminal Ready (DTR) signal and lowers the Request To Send (RTS) signal.


DONE string opt

Optional. Terminates the script with a Success status and writes the optional string to the gateway's log file.


ERROR string opt

Optional. Terminates the script with an error status and writes the optional string to the gateway's log file.


LOG string

Writes the string to the gateway's log file.


GOTO label

Jumps to the specified label in the script. Forward and backward jumps are allowed.


PAUSE integer

Halts the execution for integer seconds.


LISTEN

The script receives characters from the line and makes a branching decision based on the IF cases within the LISTEN statement. At least one IF case must be included and a total of four are allowed.

A time limit is optional in the LISTEN statement. In such a case, the listening terminates only when the connection times out, or if an error occurs. If a time limit is not specified, then the TIMEOUT case cannot be used in the statement.

The following sample listens on the line for only 10 seconds. During that time, if it receives the string login:, it sends the words "my name" to the line and proceeds to the next statement in the script.

LISTEN FOR 10 
IF "login:" SEND "my name"
IF TIMEOUT GOTO END
ENDLISTEN
LOG "User id has been sent"


Script File Syntax

The formal definition of syntax for the script is given below.

Make sure that you leave a blank line at the end of each script. If not, the gateway is unable to parse the script and the message "Syntax error: Invalid Statement" appears in the log file.

Script> := statementlist 

statementlist := statement statementlist

statement := label opt simplestatement
label opt listen

simplestatement := SEND string
ERROR string opt
LOG string
DONE string opt
GOTO integer
PAUSE integer
SETDTR
SETRTS
CLRDTR
CLRRTS

listen := LISTEN FOR timelimit
IF string simplestatement
IF TIMEOUT simplestatement
ENDLISTEN

timelimit:= integer
EVER

label := alphanumtext:

string := "text"

alphanumtext := a-zA-Z_0-9

integer := 0-9

text := any character

IMPORTANT:   There is a difference between sending raw data to a COM port and a modem. If you embed modem commands in your script, such commands should be followed by \r. For example, if you want to instruct a modem to dial the number 555-1212, the instruction would be sent to the modem as follows:

SEND "atdt 555-1212\r"


Sample Scripts


Sample Script for Logging In
LOG "Starting the login..." 
SEND "something important..." #This is a comment
PAUSE 5
LABEL1:
LISTEN FOR 10
IF "login" SEND "my name"
IF TIMEOUT GOTO LABEL2
ENDLISTEN
LOG "Sent the userid..."
LISTEN FOR 20
IF "passwd" SEND "my password"
IF TIMEOUT GOTO LABEL2
ENDLISTEN
DONE "Login successful!"
LABEL2:
ERROR "Login failed"

Sample Script for Initialization and Dialing
LOG "Initiating Link Specific Script for Connection: Primary" 
LOG "Initializing the Modem"
LISTEN FOR 5
IF "RING" GOTO LABEL5
IF "BUSY" GOTO LABEL6
ENDLISTEN
SEND "AT&FX4E0V1&M4&B1&C1&D2&H1&K0&R2S0=2\r" #Init String

# NOTE: Modem commands should
# be followed by "\r".
LISTEN FOR 10
IF "OK" GOTO LABEL1
IF TIMEOUT GOTO LABEL3
ENDLISTEN
LABEL1:
LOG "Modem Successfully Initialized"
LOG "Dialing"
SEND "atdt 555-1212\r "# Dial
LISTEN FOR 30
IF "CONNECT" GOTO LABEL2
IF TIMEOUT GOTO LABEL4
ENDLISTEN
LABEL2:
DONE "Connected!"
LABEL3:
ERROR "The Modem Is Not Responding."
LABEL4:
LOG "Unable to Dial 555-1212."
PAUSE 1
SEND "athz\r "# Hang up
PAUSE 1
LOG "Dialing 555-1414."
SEND "atdt 555-1414\r "# Dial alternate number
LISTEN FOR 30
IF "CONNECT" GOTO LABEL2
IF TIMEOUT GOTO LABEL4
ENDLISTEN
LABEL5:
DONE "Aborting Script to Answer Inbound call."
LABEL6:
DONE "The Line is BUSY. Aborting script."
LABEL7:
DONE "Unable to Dial"