Using SAS/CONNECT Script Files |
Writing Simple SAS/CONNECT Scripts: Overview |
When you write or modify existing SAS/CONNECT scripts, use the WAITFOR and TYPE statements to specify the sequence of prompts and responses for the server.
The simplest method for determining the sequence is to manually reproduce on the server the process that you want to capture in the WAITFOR and TYPE statements. For each display on the server, choose a word from that display for the WAITFOR statement. Whatever information you type to respond to a display should be specified in a TYPE statement. Be sure to note all carriage returns or other special keys.
If the server runs under z/OS 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 z/OS server interprets the hyphen as the continuation of the TYPE statement from the previous line. For example, here is how to divide the following TYPE statement:
type "sas options ('dmr comamid=tcp')" enter;
type "sas options ('dmr comamid=-" enter; type "tcp')" enter;
Note: Do not insert spaces before or after the hyphen.
Example SAS/CONNECT Script for a TCP/IP Connection to UNIX |
/* 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 operating environment */ /* via the TCP/IP access method */ /* */ /* notes: 1. This script might need */ /* modifications that account */ /* for the local flavor of */ /* your UNIX environment. The */ /* logon procedure should */ /* mimic the tasks that you */ /* execute when */ /* connecting to the same */ /* UNIX operating environment. */ /* */ /* 2. You must have specified */ /* OPTIONS COMAMID=TCP in the */ /* client 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 server. */ /****************************************/ 7 type 'sas -dmr -comamid tcp -device grlink -noterminal -nosyntaxcheck' LF; 8 waitfor 'SESSION ESTABLISHED', 90 seconds : nosas; 9 log 'NOTE: SAS/CONNECT conversation established.'; stop; /*******************************************/ /* TCP/IP SIGNOFF */ /*******************************************/ 10 signoff: 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;
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.