Chapter Contents |
Previous |
Next |
SAS/CONNECT User's Guide |
When you are writing scripts or modifying existing scripts, the WAITFOR and TYPE statements require special attention to detail. To ensure that the script recognizes the expected prompt for each stage of signing on, you must be careful to specify the exact sequence of prompts and responses for the remote host.
The simplest method for determining these is to go to the remote host and manually go through the process that you want to capture in the WAITFOR and TYPE statements. For each display on the remote host, choose a word from that display for the WAITFOR statement. Whatever information you type to respond to a display should be specified in the TYPE statement. Be sure to note all carriage returns or other special keys.
If OS/390 is the remote host and you need to use a TYPE statement that has more than 80 characters in a sign-on script, divide the TYPE statement into two or more TYPE statements. To divide the TYPE statement, insert a hyphen (-) at the division point. The remote OS/390 host interprets the hyphen as the continuation of the TYPE statement from the previous line. For example, to divide the following TYPE statement:
type "sas options ('dmr comamid=pclink')" enter;
change it to:
type "sas options ('dmr comamid=-" enter; type "pclink')" enter;
Note: Do not add any spaces around the hyphen.
Script for EHLLAPI Connections |
/* trace on; */ /* echo on; */ /*********************************************/ /* Copyright (C) 1990 by */ /* SAS Institute Inc., Cary NC */ /* */ /* name: tso.scr */ /* */ /* purpose: SAS/CONNECT SIGNON/SIGNOFF */ /* script for connecting to an */ /* OS/390 (with TSO) host by using */ /* the EHLLAPI access method */ /* */ /* notes: The communication parameters may */ /* need to be changed for your site */ /* */ /* assumes: 1. This script assumes that the */ /* remote session is already */ /* logged on. */ /* */ /* 2. The command to execute SAS in */ /* your remote OS/390 (with TSO) */ /* environment is "sas". If */ /* this is incorrect for your */ /* site, change the contents of */ /* the line that contains: */ /* type "sas ... */ /* */ /* support: SAS Institute staff */ /*********************************************/ [1] log "NOTE: Script file 'tso.scr' entered."; [2] if signoff then goto signoff; /*********************************************/ /* EHLLAPI SIGNON */ /*********************************************/ [3] waitfor 'READY', 0 seconds: noinit; log 'NOTE: Starting remote SAS now.'; /******************************************/ /* NOTERMINAL suppresses prompts from */ /* remote SAS session. NO$SYNTAXCHECK */ /* prevents remote side from going */ /* into syntax checking mode when a */ /* syntax error is encountered. */ /******************************************/ type "sas options('dmr,comamid=pclink, noterminal,no$syntaxcheck')" enter; [4] continue: waitfor 'IN PROGRESS', 20 seconds: waitsas; [5] onok: log 'NOTE: SAS/CONNECT conversation established.'; stop; /*********************************************/ /* EHLLAPI SIGNOFF */ /*********************************************/ [6] signoff: log 'NOTE: SAS/CONNECT conversation terminated.'; log 'NOTE: Remote session left logged on.'; stop; /*********************************************/ /* SUBROUTINES */ /*********************************************/ [7] waitsas: log 'NOTE: Waiting for startup screen...'; type EREOF enter; goto continue; /*********************************************/ /* ERROR HANDLING */ /*********************************************/ [8] noinit: snapshot; log 'ERROR: Did not get remote prompt. Remote session not active.'; log 'NOTE: You must log on to the remote session before signing on using this script file.'; abort; [9] nosas: snapshot; log 'ERROR: Did not get SAS software startup messages.'; abort;
LOG statements write messages to the local host's SAS log providing information about the progress of the SIGNON. | |
The IF statement tests for a limited set of conditions and then directs processing to the appropriate statement label. For example, if the SIGNOFF command or statement invokes this script, processing jumps to the SIGNOFF label. See step 6 in this list. | |
These statements write the message to the local host's log. The WAITFOR statement looks for the remote host READY prompt and processing goes to step 8 if no prompt is received. When the READY prompt is received, the TYPE statement invokes the SAS System on the remote host. The DMR system option is necessary to invoke a special processing mode for SAS/CONNECT. The COMAMID= system option specifies the access method that is used to establish the connection. The DEVICE= option specifies the GRLINK graphics device driver in case you'll be doing remote graphics processing. | |
The WAITFOR statement looks for the message
IN PROGRESS , which is displayed when a SAS session starts on the remote host. If the message is not found, processing goes to the WAITSAS label in step 7. | |
This LOG statement prints a message to the log to indicate that you have successfully established a connection. | |
These statements are executed when step 2 directs processing here. The two notes are written to the local log, and the connection is terminated. | |
Processing continues from step 4. The note is written to the local log, and processing returns to step 4. | |
The SNAPSHOT statement captures messages displayed on the remote host and writes them to the local host's log. The log messages can help you determine what has occurred on the remote host that interrupted the sign on. You can save or print the local log to have a record of these messages. The error and note messages are written to the local log, and the script aborts. | |
The SNAPSHOT statement captures messages displayed on the remote host and writes them to the local host's log. The log messages can help you determine what has occurred on the remote host that interrupted the sign on. You can save or print the local log to have a record of these messages. The error message is written to the local log, and the script aborts. |
Script for TCP/IP Connections |
/* trace on; */ /* echo on; */ /*******************************************/ /* Copyright (C) 1990 */ /* by SAS Institute Inc., Cary NC */ /* */ /* name: tcpunix.scr */ /* */ /* purpose: SAS/CONNECT SIGNON/SIGNOFF */ /* script for connecting to any */ /* UNIX host via the TCP/IP access*/ /* method */ /* */ /* notes: 1. This script may need */ /* modifications that account */ /* for the local flavor of */ /* your UNIX environment. The */ /* logon procedure should */ /* mimic the events that you */ /* go through when */ /* "telnet"-ing to the same */ /* UNIX host. */ /* */ /* 2. You must have specified */ /* OPTIONS COMAMID=TCP in the */ /* local SAS session before */ /* using the SIGNON command. */ /* */ /* assumes: 1. The command to execute SAS */ /* in your remote (UNIX) */ /* environment is "sas". If */ /* this is incorrect for your */ /* site, change the contents */ /* of the line that contains */ /* type 'sas ... */ /* */ /* support: SAS Institute staff */ /*******************************************/ [1] log "NOTE: Script file 'tcpunix.scr' entered."; if not tcp then goto notcp; [2] if signoff then goto signoff; /*******************************************/ /* TCP/IP SIGNON */ /*******************************************/ [3] waitfor 'login:', 120 seconds: noinit; /*******************************************/ /* UNIX LOGON */ /* LF is required to turn the line */ /* around after the login name has */ /* been typed. (CR will not do) */ /*******************************************/ [4] input 'Userid?'; type LF; [5] waitfor 'Password', 30 seconds : nolog; input nodisplay 'Password?'; type LF; unx_log: /*******************************************/ /* Common prompt characters are $,>,%,} */ /*******************************************/ [6] waitfor '$', '>', '%', '}', 'Login incorrect' : nouser, 'Enter terminal type' : unx_term, 30 seconds : timeout; log 'NOTE: Logged onto UNIX... Starting remote SAS now.'; /****************************************/ /* Invoke SAS on the remote host. */ /****************************************/ [7] type 'sas -dmr -comamid tcp -device grlink -noterminal -no\$syntaxcheck' LF; [8] waitfor 'SESSION ESTABLISHED', 90 seconds : nosas; [9] log 'NOTE: SAS/CONNECT conversation established.'; stop; /*******************************************/ /* TCP/IP SIGNOFF */ /*******************************************/ signoff: [10] waitfor '$', '>', '%', '}', 30 seconds; type 'logout' LF; log 'NOTE: SAS/CONNECT conversation terminated.'; stop; /*******************************************/ /* SUBROUTINES */ /*******************************************/ unx_term: /****************************************/ /* Some UNIX systems want the */ /* terminal-type. Indicate a basic */ /* tele-type. */ /****************************************/ type 'tty' LF; goto unx_log; /*******************************************/ /* ERROR ROUTINES */ /*******************************************/ [11] timeout: log 'ERROR: Timeout waiting for remote session response.'; abort; nouser: log 'ERROR: Unrecognized userid or password.'; abort; notcp: log 'ERROR: Incorrect communications access method.'; log 'NOTE: You must set "OPTIONS COMAMID=TCP;" before using this script file.'; abort; noinit: log 'ERROR: Did not understand remote session banner.'; nolog: log 'ERROR: Did not receive userid or password prompt.'; abort; nosas: log 'ERROR: Did not get SAS software startup messages.'; abort;
The LOG statement sends the message that is enclosed in quotation marks to the log file or the log window of the local SAS session. Although it is not necessary to include LOG statements in your script file, the LOG statements keep the user informed about the progress of the connection. | |
The IF/THEN statement detects whether the script was called by the SIGNON command or statement or the SIGNOFF command or statement. When you are signing off, the IF/THEN statement directs script processing to the statement labeled SIGNOFF. See step 10. | |
The WAITFOR statement waits for the remote host's logon prompt and specifies that if that prompt is not received within 120 seconds, the script processing should branch to the statement labeled NOINIT. | |
The INPUT statement displays a window
with the text
Userid? to allow the user to enter a remote host logon userid. The TYPE statement sends a line feed to the remote host to enter the userid to the remote
host. | |
The WAITFOR statement waits for the remote host's password prompt and branches to the NOLOG label if it is not received within 30 seconds. The INPUT statement that follows the WAITFOR statement displays a window for the user to enter a password. The NODISPLAY option is used so the password is not displayed on the screen as it is entered. | |
The WAITFOR statement waits for one of several common UNIX prompts and branches to various error handles if a prompt is not seen. Verify that the WAITFOR statement in the script looks for the correct prompt for your site. | |
This TYPE statement invokes the SAS System on the remote host. The DMR option is necessary to invoke a special processing mode for SAS/CONNECT. The COMAMID= option specifies the access method that is used to make the connection. The NOTERMINAL system option suppresses the prompts from the remote SAS session. The NO$SYNTAXCHECK option prevents the remote session from going into syntax checking mode when a syntax error is encountered. | |
The phrase
SESSION ESTABLISHED is displayed when a SAS session is started on the remote host by using the DMR and COMAMID=TCP options. The WAITFOR statement looks for the words
SESSION ESTABLISHED to be issued by the remote host to know that the connection has been established. If the
SESSION ESTABLISHED response is received within 90 seconds, processing continues with the next LOG statement. If the
SESSION ESTABLISHED response does not occur within 90 seconds, the script assumes that the remote SAS session has not started and processing branches to the statement labeled
NOSAS. | |
When the connection has been successfully established, you must stop the rest of the script from processing. Without this STOP statement, processing of the remaining statements in the script continues. | |
[10] This section of code is executed when the script is invoked to terminate
the connection. The first IF statement (see step 2) sends processing to this section of the script when the script is invoked by a SIGNOFF command or statement. Note that this section waits for a
remote host prompt before typing
LOGOUT in order to log off the remote host. The script then issues a
LOG statement to notify the user that the connection is terminated and stops the connection. | |
[11] These statements are processed only if the prompts expected in the previous steps are not received. This section of the script issues messages to the local SAS log and then abnormally ends (from the ABORT statement) the processing of the script as well as the sign on. |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.