Chapter Contents |
Previous |
Next |
Communications Access Methods for SAS/CONNECT and SAS/SHARE Software |
The following script connects to a UNIX remote host with the TCP/IP access method.
/* trace on; */ /* echo on; */ /*-------------------------------------------------------------------*/ /*-- Copyright (C) 1996 by SAS Institute Inc., Cary NC --*/ /*-- --*/ /*-- name: tcpunix.scr --*/ /*-- --*/ /*-- purpose: SAS/CONNECT SIGNON/SIGNOFF script for connecting --*/ /*-- to any UNIX host by means of 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. If you are connecting to a spawner --*/ /*-- that is running in your UNIX environment, this --*/ /*-- script should need little or no modifications. --*/ /*-- --*/ /*-- 2. You must have specified OPTIONS COMAMID=TCP --*/ /*-- in the local SAS session before using the SIGNON --*/ /*-- statement. --*/ /*-- --*/ /*-- 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 --*/ /*-- --*/ /*-------------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /*-- if you are connecting to DEC ULTRIX, and the remote --*/ /*-- machine does not run the DECnet connection/gateway --*/ /*-- software, logins by means of SAS/CONNECT will appear to --*/ /*-- hang. This is due to the ULTRIX "/etc/telnetd" server --*/ /*-- treating a DONT ECHO request for both input and output --*/ /*-- streams. --*/ /*-- --*/ /*-- This DEBUG statement causes the SAS TCP/IP access method --*/ /*-- not to reply to the ECHO request, keeping the DEC telnetd --*/ /*-- server happy. --*/ /*-- --*/ /*-- Uncomment the DEBUG statement, if the logon appears to hang--*/ /*----------------------------------------------------------------*/ /* debug '00001000'; */ /*----------------------------------------------------------------*/ /*-- If you are connecting to INTEL ABI, you need to uncomment --*/ /*-- the following DEBUG statement. This DEBUG statement --*/ /*-- allows SAS/CONNECT to set the terminal type to TTY during --*/ /*-- the TELNET negotiations that take place during SIGNON. --*/ /*----------------------------------------------------------------*/ /* debug '00004000'; */ [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:' , 'Username:' , 'Scripted signon not allowed' : noscript , 120 seconds: noinit; /*----------------UNIX LOGON---------------------------------------*/ /*-- for some reason, it needs an LF 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: [6] waitfor 'Hello>' : unxspawn /*- UNIX spawner prompt-*/ , '$' /*-- a common prompt character --*/ , '>' /*-- another common prompt character --*/ , '%' /*-- another common prompt character --*/ , '}' /*-- another common prompt character --*/ , 'Login incorrect' : nouser , 'Enter terminal type' : unx_term , 'TERM' : unx_term , 30 seconds : timeout ; log 'NOTE: Logged onto UNIX... 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. */ [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; [10] unxspawn: /* The UNIX spawner executes only a single UNIX command */ /* after the client logs on. In the TYPE statement below, */ /* you may specify a SAS command line. You may also specify */ /* a UNIX shell script that issues the SAS command line in */ /* addition to any other commands to be executed prior to */ /* SAS invocation. The following is a sample startup */ /* file: */ /*#---------------------------------------------------------*/ /*# sas_startup */ /*#---------------------------------------------------------*/ /*#!/bin/ksh */ /*. ~/.profile */ /*sas -dmr -noterminal -no\$syntaxcheck -device grlink */ /*#---------------------------------------------------------*/ /* */ /* If you choose to use a "startup" file, change the TYPE */ /* statement below to something like the following: */ /* type '/usr/local/whatever/sas_startup' LF; */ [11] type 'sas -dmr -comamid tcp -device grlink -noterminal '; type '-no\$syntaxcheck' LF; waitfor 'SESSION ESTABLISHED', 90 seconds : nosas; stop; /*---------------- TCP/IP SIGNOFF --------------------------------------*/ signoff: /* If you have established your connection to UNIX by means */ /* of a UNIX spawner, you should delete or comment the */ /* following WAITFOR and TYPE statements. They are not */ /* necessary for signing off a UNIX spawner and will */ /* result in slower performance of SIGNOFF. */ [12] waitfor '$' , '>' /*-- another common prompt character --*/ , '%' /*-- another common prompt character --*/ , '}' /*-- another common prompt character --*/ , 30 seconds ; type 'logout' LF; log 'NOTE: SAS/CONNECT conversation terminated.'; stop; /*--------------- SUBROUTINES -----------------------------------*/ unx_term: /*---------------------------------------------------------------*/ /*-- Some UNIX platforms want the terminal type, --*/ /*-- so tell them we are the most basic of terminals. --*/ /*---------------------------------------------------------------*/ type 'tty' LF; goto unx_log; /*--------------- ERROR ROUTINES --------------------------------*/ [13] 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'; log ' 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; noscript: /* This is the result of trying to sign on with a script file */ /* to a UNIX spawner that has been invoked with the -NOSCRIPT */ /* option. You need to clear any script file reference and */ /* then re-execute SIGNON. */ log 'ERROR: Scripted signons are not allowed.'; log 'NOTE: Clear any script file reference and retry SIGNON.'; abort;
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.
unxspawn
label in step 10. Verify that the WAITFOR statement in the
script looks for the correct prompt for your site.
SESSION ESTABLISHED
is displayed when a SAS session
is started on the remote host with the DMR and the COMAMID=TCP options. The
WAITFOR statement awaits the display of the message
SESSION ESTABLISHED
to
be issued by the remote host. 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.
LOGOFF
. Before it stops
the link, the script issues a LOG statement to notify the user that the link
is terminated.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.