Previous Page | Next Page

Sign-On Scripts

Sample Scripts


The Scripts

TCPUNIX.SCR Script

TCPWIN.SCR Script

TCPMVS.SCR Script

TCPTSO9.SCR Script


TCPUNIX.SCR Script

The following script connects a client to a UNIX server by using the TCP/IP access method.

/* trace on; */
/* echo  on; */
/*-------------------------------------------------------------------*/
/*--            Copyright (C) 2007 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 might need modifications that account --*/
/*--             for the local flavor of your UNIX environment.    --*/
/*--             The logon process should mimic the tasks that     --*/
/*--             you perform 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 few 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.                                                   --*/
   /*--                                                            --*/
   /*-- The 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 can specify a SAS command line. You can 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 start-up      */
      /* 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 similar to 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 using */
    /* 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 this is 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 start-up 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;

  1. The LOG statement sends the quoted message to the log file or to the Log window of the SAS session at the client. Although it is unnecessary to include LOG statements in your script file, the LOG statements keep the user informed about the progress of the connection.

  2. The IF/THEN statement can detect whether the script was called by the SIGNON statement or the SIGNOFF statement. When you are signing off, the IF/THEN statement directs script processing to the statement labeled SIGNOFF. See step 12.

  3. The WAITFOR statement awaits the login prompt from the server. If the statement does not receive the prompt within 120 seconds, it directs script processing to branch to the statement labeled NOINIT.

  4. The INPUT statement displays a window with the text Userid? to allow the user to enter a server logon user ID. The TYPE statement sends a line feed to the server to enter the user ID to the server.

  5. The WAITFOR statement waits for the password prompt from the server 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 in which the user enters a password.

  6. The WAITFOR statement waits for one of several common UNIX prompts and branches to various error handles if a prompt is not displayed. For a connection to the UNIX spawner, the string "Hello >" is received and the control branches to the unxspawn label in step 10. Verify that the WAITFOR statement in the script looks for the correct prompt for your site.

  7. The TYPE statement invokes SAS on the server. 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.

  8. The message SESSION ESTABLISHED is displayed when a SAS session is started on the server by using the options -DMR and -COMAMID TCP. The WAITFOR statement awaits the display of the message SESSION ESTABLISHED to be issued by the server. 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.

  9. After the connection has been successfully established, the user must stop the rest of the script from processing. Without this STOP statement, processing continues through the remaining statements in the script.

  10. This section of code is executed when you connect to a remote UNIX spawner.

  11. The TYPE statement invokes SAS on the server. 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.

  12. This section of code is executed when the script is invoked to terminate the link. The IF statement (see step 2) sends processing to this section of the script when the script is invoked by a SIGNOFF statement. This section logs the user off the server after the user executes LOGOFF . Before it stops the link, the script issues a LOG statement to notify the user that the link is terminated.

  13. 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 SAS log at the client and then abnormally ends the script processing as well as the SIGNON.


TCPWIN.SCR Script

The following script signs a client on and off a Windows server by using the TCP/IP access method.

/* trace on; */
/* echo  on; */
/*-------------------------------------------------------------------*/
/*--            Copyright (C) 2007 by SAS Institute Inc., Cary NC  --*/
/*--                                                               --*/
/*-- name:      tcpwin.scr                                         --*/
/*--                                                               --*/
/*-- purpose:   SAS/CONNECT SIGNON/SIGNOFF script for connecting   --*/
/*--            to a Windows host by                               --*/
/*--            using the TCP/IP access method.                    --*/
/*--                                                               --*/
/*-- notes:   1. You must have the spawner program executing on    --*/
/*--             the remote Windows workstation                    --*/
/*--             in order for the local session to be able to      --*/
/*--             establish the connection.  If the spawner is      --*/
/*--             running on the remote node, you will receive a    --*/
/*--             message that tells you that the connection has    --*/
/*--             been refused.                                     --*/
/*--                                                               --*/
/*--          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         --*/
/*--             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 'tcpwin.scr' entered.";

     if not tcp then goto notcp;
2  if signoff then goto signoff;

     /* --------------- TCP/IP SIGNON ---------------------------------*/

3  waitfor 'Username:'
           , 'Hello>'                :  ready
           , 'access denied'         :  nouser
           , 120 seconds             :  noprompt
           ;
4  input 'Userid?';
     type LF;
5  waitfor 'Password:' , 120 seconds: nolog;
     input nodisplay 'Password?';
     type LF;

6  waitfor 'Hello>'
           , 'access denied'         :  nouser
           , 120 seconds             :  timeout
           ;

  ready:
     log 'NOTE: Logged onto Windows... 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', 120 seconds : nosas;

9  log 'NOTE: SAS/CONNECT conversation established.';
     stop;


/*---------------- TCP/IP SIGNOFF -----------------------------------*/

10  signoff:
     log 'NOTE: SAS/CONNECT conversation terminated.';
     stop;

/*--------------- SUBROUTINES -----------------------------------*/


/*--------------- ERROR ROUTINES --------------------------------*/
11 
  notcp:
     log 'ERROR: Incorrect communications access method.';
     log 'NOTE: You must set "OPTIONS COMAMID=TCP;" before using this';
     log '      script file.';
     abort;

  noprompt:
     log 'ERROR: Did not receive userid prompt.';
     log 'NOTE:  Ensure spawner process is running on remote node.';
     abort;

  nolog:
     log 'ERROR: Did not receive password prompt.';
     abort;


  nouser:
     log 'ERROR: Unrecognized userid or password.';
     abort;

  nosas:
     log 'ERROR: Did not get SAS software startup messages.';
     abort;

  timeout:
     log 'ERROR: Timeout waiting for remote session response.';
     abort;

  1. The LOG statement sends the quoted message to the log file or to the Log window of the SAS session at the client. 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.

  2. The IF/THEN statement detects whether the script was called by the SIGNON statement or by the SIGNOFF statement. When you sign off, the IF/THEN statement directs script processing to the statement that is labeled SIGNOFF. See step 10.

  3. The WAITFOR statement awaits the login prompt from the server and branches to various error handles if the prompt is not displayed.

  4. The INPUT statement displays a window with the text Userid? to allow the user to enter a server logon user ID. The TYPE statement sends a line feed to the server to enter the user ID to the server.

  5. The WAITFOR statement awaits the password prompt from the server and branches to the NOLOG label if it is not received within 120 seconds. The INPUT statement that follows the WAITFOR statement displays a window in which the user enters a password.

  6. The WAITFOR statement awaits the "Hello > " prompt that it expects to see from the Windows spawner. If the statement does not receive the prompt within 120 seconds, it directs script processing to branch to the statement that is labeled TIMEOUT.

  7. The TYPE statement invokes SAS on the server. 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.

  8. The message SESSION ESTABLISHED is displayed when a SAS session is started on the server by using the -DMR and -COMAMID TCP options. The WAITFOR statement awaits the display of the message SESSION ESTABLISHED to be issued by the server. If the SESSION ESTABLISHED response is received within 120 seconds, processing continues with the next LOG statement. If the SESSION ESTABLISHED response does not occur within 120 seconds, the script assumes that the remote SAS session has not started and processing branches to the statement labeled NOSAS.

  9. After the connection has been successfully established, the user must stop the rest of the script from processing. Without this STOP statement, processing continues through the remaining statements in the script.

  10. This section of code is executed when the script is invoked to terminate the link. The IF statement (see step 2) sends processing to this section of the script when the script is invoked by a SIGNOFF statement. Before it stops the link, the script issues a LOG statement to notify the user that the link is terminated.

  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 SAS log at the client and then abnormally ends the script processing as well as the SIGNON.


TCPMVS.SCR Script

The following script enables a client to sign on and to sign off a z/OS server with TSO. The TCP/IP access method is used.

/*-------------------------------------------------------------------*/
/*--            Copyright (C) 2007 by SAS Institute Inc., Cary NC  --*/
/*--                                                               --*/
/*-- name:      tcpmvs.scr                                         --*/
/*--                                                               --*/
/*-- purpose:   SAS/CONNECT SIGNON/SIGNOFF script for connecting   --*/
/*--            to a z/OS host via the TCP/IP access method        --*/
/*--                                                               --*/
/*-- notes:   1. This script might need modifications that account --*/
/*--             for the local flavor of your z/OS environment.    --*/
/*--             The logon procedure should mimic the tasks that   --*/
/*--             you perform when "telnet"-ing to the same         --*/
/*--             z/OS host through TSO.                            --*/
/*--                                                               --*/
/*--          2. You must have specified OPTIONS COMAMID=TCP       --*/
/*--             in the local SAS session before using the SIGNON  --*/
/*--             command.                                          --*/
/*--                                                               --*/
/*--          3. This script supports one flavor of connection:    --*/
/*--             through a TSO session whose logon procedure       --*/
/*--             invokes SAS directly rather than the TSO TMP.     --*/
/*--                                                               --*/
/*-- support:   SAS Institute staff                                --*/
/*--                                                               --*/
/*-------------------------------------------------------------------*/

1    log "NOTE: Script file 'tcpmvs.scr' entered.";

   if not tcp then goto notcp;
2    if signoff then goto signoff;

/* ------------------------ TCP SIGNON ------------------------------*/

   /* make sure you are running the IBM TCP/IP */
3    waitfor 'ENTER USERID'                 : tsologon,
           120 seconds                    : noinit;

/*-------------------------- TSO LOGON ------------------------------*/

tsologon:
4    input 'Userid?';
   type LF;
5    waitfor 'ENTER PASSWORD', 60 seconds : nolog;

tsopass:
   input nodisplay 'Password?';
   type LF;

tsodone:
6   waitfor 'SESSION ESTABLISHED',
           'PASSWORD INVALID'             : tsopass,
           'ENTER NEW PASSWORD'           : tsonewp,
           'CURRENTLY LOGGED ON'          : dup_log,
           'NOT VALID'                    : nouser,
           120 seconds                    : notso;
   waitfor 1 second;

7    log 'NOTE: SAS/CONNECT conversation established.';
   stop;

tsonewp:
8    input nodisplay 'New Password?';
   type LF;

9   waitfor 'VERIFY NEW PASSWORD',
           120 seconds                    : notso;

   input nodisplay 'Verify New Password';
   type LF;

   goto tsodone;

/*---------------------------- SIGNOFF ------------------------------*/
10  signoff:
   type 'logoff' LF;
   waitfor 'LOGGED OFF'                   : logoff,
           20 seconds;

   log 'WARNING: Did not get messages confirming logoff.';
   abort;

logoff:
   log 'NOTE: SAS/CONNECT conversation terminated.';
   stop;

/*----------------------- TSO ERROR ROUTINES ------------------------*/

11  nouser:
   log 'ERROR: Unrecognized userid.';
   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.';
   abort;

nolog:
   log 'ERROR: Did not get userid or password prompt.';
   abort;

notso:
   log 'ERROR: Did not get TSO startup messages after logon.';
   abort;

dup_log:
   log 'ERROR: User is already logged onto TSO.';
   abort;

  1. The LOG statement sends the quoted message to the log file or to the Log window of the SAS session at the client. 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.

  2. The IF/THEN statement detects whether the script was called by the SIGNON statement. When you are signing off, the IF/THEN statement directs script processing to the statement labeled SIGNOFF. See step 10.

  3. The WAITFOR statement awaits the login prompt from the server. If the statement does not receive the prompt within 120 seconds, it directs script processing to branch to the statement labeled NOINIT.

  4. The INPUT statement displays a window with the text Userid? to allow the user to enter a server logon user ID. The TYPE statement sends a line feed to the server to enter the user ID to the server.

  5. The WAITFOR statement waits for the password prompt from the server and branches to the NOLOG label if it is not received within 60 seconds. The INPUT statement that follows the WAITFOR statement displays a window for the user to enter a password.

  6. The message SESSION ESTABLISHED is displayed when a SAS session is started on the server. The WAITFOR statement awaits the display of the message SESSION ESTABLISHED to be issued by the server. If the SESSION ESTABLISHED response is received within 120 seconds, processing continues with the next LOG statement. If the SESSION ESTABLISHED response does not occur within 120 seconds, the script assumes that the remote SAS session has not started and processing branches to the statement labeled NOTSO.

  7. After the connection has been successfully established, the user must stop the rest of the script from processing. Without this STOP statement, processing continues through the remaining statements in the script.

  8. This section prompts for a new password if the password has expired. The INPUT statement displays a window with the text New Password? to allow the user to enter a password. The TYPE statement sends a line feed to the server to enter the password to the server.

  9. The WAITFOR statement waits for the prompt to verify the new password from the server and branches to the NOTSO label if it is not received within 120 seconds. The INPUT statement that follows the WAITFOR statement displays a window in which the user re-enters the new password for verification.

  10. This section of code is executed when the script is invoked to terminate the link. The IF statement (see step 2) sends processing to this section of the script when the script is invoked by a SIGNOFF statement. This section awaits a server prompt before displaying LOGOFF , which logs the user off the server. Before it stops the link, the script issues a LOG statement to notify the user that the link is terminated.

  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 SAS log at the client and then abnormally ends the script processing as well as the SIGNON.


TCPTSO9.SCR Script

The following script enables a client to sign on and to sign off a z/OS server with TSO or to a z/OS spawner. The TCP/IP access method is used.

/* trace on; */
/* echo on;  */
/*-------------------------------------------------------------------*/
/*--            Copyright (C) 2007 by SAS Institute Inc., Cary NC  --*/
/*--                                                               --*/
/*-- name:      tcptso9.scr                                        --*/
/*--                                                               --*/
/*-- purpose:   SAS/CONNECT SIGNON/SIGNOFF script for connecting   --*/
/*--            to a z/OS host running SAS 9 or later via the      --*/
/*--            TCP/IP access method.                              --*/
/*--                                                               --*/
/*-- notes:   1. This script might need modifications that account --*/
/*--             for the local flavor of your z/OS environment.    --*/
/*--             The logon procedure should mimic the tasks that   --*/
/*--             you perform when "telnet"-ing to the same         --*/
/*--             z/OS host, either to TSO or to the z/OS           --*/
/*--             spawner.                                          --*/
/*--                                                               --*/
/*--          2. You must have specified OPTIONS COMAMID=TCP       --*/
/*--             in the local SAS session before using the SIGNON  --*/
/*--             command.                                          --*/
/*--                                                               --*/
/*--          3. This script supports two flavors of connection:   --*/
/*--             through a TSO session whose logon procedure       --*/
/*--             invokes the TSO TMP or through the z/OS           --*/
/*--             spawner.                                          --*/
/*--                                                               --*/
/*--          4. If you use the spawner to start the SAS session,  --*/
/*--             in the signoff portion of the script, comment the --*/
/*--             LOGOFF command, which is only needed to complete  --*/
/*--             TSO session termination and is not necessary for  --*/
/*--             a spawned session.                                --*/
/*--                                                               --*/
/*-- assumes: 1. The shell script to execute SAS in your remote    --*/
/*--             z/OS environment is:                              --*/
/*--                "/usr/local/bin/spawnsas.sh"                   --*/
/*--             If you are using a different shell script or have --*/
/*--             your shell script stored in a different location, --*/
/*--             change the contents of the type statement that    --*/
/*--             specifies this shell script:                      --*/
/*--                type "/usr/local/bin/spawnsas.sh ..." LF;      --*/
/*--                                                               --*/
/*--          2. The command to execute SAS in your remote         --*/
/*--             (MVS/TSO) environment is "sas". If this is        --*/
/*--             incorrect for your site, change the contents of   --*/
/*--             the line for connection through TSO that          --*/
/*--             contains:                                         --*/
/*--                type "sas ..." lf;                             --*/
/*--                                                               --*/
/*-- support:   SAS Institute staff                                --*/
/*--                                                               --*/
/*-------------------------------------------------------------------*/

1    log "NOTE: Script file 'tcptso9.scr' entered.";

   if not tcp then goto notcp;
2   if signoff then goto signoff;

/* ------------------------ TCP SIGNON ------------------------------*/

   /* make sure you are running the IBM TCP/IP or the z/OS spawner   */
3    waitfor 'Username:'                    : spnlogon,
           'ENTER USERID'                 : tsologon,
           120 seconds                    : noinit;

/*------------------------- SPAWNER LOGON ---------------------------*/

spnlogon:
4    input 'Userid?';
   type LF;

5    waitfor 'Password', 120 seconds : spnfail;
   input nodisplay 'Password?';
   type LF;

spndone:
6    waitfor 'Hello>',
           'Userid'                       : spnlogon,
           'Password expired'             : spnnewp,
           120 seconds                    : spnfail;

7   type "/usr/local/bin/spawnsas.sh nosasuser opt(''dmr comamid=tcp'')" LF;

8   waitfor 'SESSION ESTABLISHED', 120 seconds : spnfail;

9  log 'NOTE: SAS/CONNECT conversation established.';
   stop;

spnnewp:
10    input nodisplay 'New Password?';
   type LF;

   waitfor 'Verify new password', 120 seconds : spnfail;

   input nodisplay 'Verify New Password';
   type LF;

   goto spndone;

spnfail:
   log 'ERROR: Invalid SPAWNER prompt message received.';
   abort;

/*-------------------------- TSO LOGON ------------------------------*/

tsologon:
11    input 'Userid?';
   type LF;
12    waitfor 'ENTER PASSWORD', 60 seconds : nolog;
   input nodisplay 'Password?';
   type LF;

tsodone:
13    waitfor 'READY',
           'CURRENTLY LOGGED ON'          : dup_log,
           'NOT VALID'                    : nouser,
           'PASSWORD INVALID'             : nopass,
           'ENTER NEW PASSWORD'           : tsonewp,
           'RECONNECT SUCCESS'            : recon,
           120 seconds                    : notso;
   waitfor 1 second;

strt_sas:
   log 'NOTE: Logged on to TSO.... Starting remote SAS now.';
   /* NOTERMINAL suppresses prompts from      */
   /* remote SAS session.  NOSYNTAXCHECK prevents remote side from        */
   /* going into syntax checking mode when a syntax error is encountered. */
14    type "sas o('dmr,comamid=TCP,noterminal,nosyntaxcheck')" LF;
15   waitfor 'SESSION ESTABLISHED', 120 seconds : nosas;

16    log 'NOTE: SAS/CONNECT conversation established.';
   stop;

tsonewp:
17    input nodisplay 'New Password?';
   type LF;

   waitfor 'VERIFY NEW PASSWORD',
           120 seconds                    : notso;

   input nodisplay 'Verify New Password';
   type LF;

   goto tsodone;

/*---------------------------- SIGNOFF ------------------------------*/
18  signoff:
/* --------- for the spawner, comment the following section ---------*/
   waitfor 'READY', 20 seconds: noterm;
   type 'logoff' LF;
   waitfor 'LOGGED OFF'                   : logoff,
           20 seconds;

   log 'WARNING: Did not get messages confirming logoff.';
   abort;

logoff:
/*---------- for the spawner, comment the previous section ----------*/

   log 'NOTE: SAS/CONNECT conversation terminated.';
   stop;

/*----- SUBROUTINES -------------------------------------------------*/

19  recon:
   log 'NOTE: Reconnected to previous session.  Old SAS session lost.';
   type LF;
   waitfor 'READY'       : strt_sas,
          120 seconds;
   log 'NOTE: Reconnected to a Running Session, but no READY prompt';
   abort;


/*--------------- ERROR ROUTINES --------------------------------*/

20  nouser:
   log 'ERROR: Unrecognized userid.';
   abort;

nopass:
   log 'ERROR: Invalid 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.';
   abort;

nolog:
   log 'ERROR: Did not get userid or password prompt.';
   abort;

notso:
   log 'ERROR: Did not get TSO startup messages after logon.';
   abort;

nosas:
   log 'ERROR: Did not get SAS software startup messages.';
   abort;

dup_log:
   log 'ERROR: User is already logged onto TSO.';
   abort;
noterm:
   log 'ERROR: Did not get READY prompt; remote session still logged on.';
   abort;

  1. The LOG statement sends the quoted message to the log file or to the Log window of the SAS session at the client. 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.

  2. The IF/THEN statement detects whether the script was called by the SIGNON statement or by the SIGNOFF statement. When you sign off, the IF/THEN statement directs script processing to the statement that is labeled SIGNOFF. See step 18.

  3. The WAITFOR statement awaits the login prompt from the server. If the statement does not receive the prompt within 120 seconds, it directs script processing to branch to the statement labeled NOINT.

  4. The INPUT statement displays a window containing a prompt for a user ID so that the user can enter a server logon user ID. The TYPE statement sends a line feed to the server to enter the user ID to the server. This section is entered when the SAS/CONNECT spawner is encountered.

  5. The WAITFOR statement waits for the password prompt from the server and branches to the SPNFAIL label if it is not received within 120 seconds. The INPUT statement that follows the WAITFOR statement displays a window for the user to enter a password in.

  6. The WAITFOR statement awaits the "Hello>" prompt that it expects to receive from the spawner. If WAITFOR does not receive the prompt, it branches to various condition handlers.

  7. The TYPE statement calls a shell script to start SAS, and it passes the options that are needed for the SAS/CONNECT session. For a sample shell script, see Defining the Shell Script for Starting SAS.

  8. The message SESSION ESTABLISHED is displayed when a SAS session is started on the server by using the DMR and COMAMID=TCP options. The WAITFOR statement awaits the display of the message SESSION ESTABLISHED that is issued by the server. If the SESSION ESTABLISHED response is received within 120 seconds, processing continues with the next LOG statement. If the response is not received in the specified time period, the script assumes that the remote SAS session has not started and processing branches to the statement labeled SPNFAIL.

  9. After the connection has been successfully established, the user must stop the rest of the script from processing. Without this STOP statement, processing continues through the remaining statements in the script. Prior to the STOP, a message is output to the log, which informs the user that the connection has been established.

  10. This section prompts for a new password if the password has expired.

  11. The INPUT statement displays a window that contains a prompt for a user ID so that the user can enter a server logon user ID. The TYPE statement sends a line feed to the server to enter the user ID to the server. This section is entered when a TSO login is encountered.

  12. The WAITFOR statement awaits the password prompt from the server and branches to the NOLOG label if it is not received within 60 seconds. The INPUT statement that follows the WAITFOR statement displays a window for the user to enter a password.

  13. The WAITFOR statement awaits the READY prompt after successful TSO logon. It branches to various condition handlers if the prompt is not received.

  14. The TYPE statement issues the command to start SAS through the TSO session, and passes options that are needed for the SAS/CONNECT session.

  15. The message SESSION ESTABLISHED is displayed when a SAS session is started on the server using the DMR and COMAMID=TCP options. The WAITFOR statement awaits the display of the message SESSION ESTABLISHED to be issued by the server. If the SESSION ESTABLISHED response is received within 120 seconds, processing continues with the next LOG statement. If the response is not received within the time limit, the script assumes that the remote SAS session has not started and processing branches to the statement labeled NOSAS.

  16. After the connection has been successfully established, the user must stop the rest of the script from processing. Without this STOP statement, processing continues through the remaining statements in the script. Prior to the STOP, a message is output to the log, which informs the user that the connection has been established.

  17. This section prompts for a new password if the password has expired.

  18. This section of code is executed when the script to terminate the link is invoked. The IF statement (see step 2) sends processing to this section of the script when the script is invoked by a SIGNOFF statement. This section awaits a server prompt before displaying LOGOFF, which logs the user off the server. Before it terminates the link, the script issues a LOG statement to notify the user that the link is terminated.

    Note:   If the session has been established through the z/OS spawner, the WAITFOR and TYPE statements should be deleted or commented out. They are necessary only for signing off a TSO connection.   [cautionend]

  19. This section handles the case where SIGNON reconnects the user to a SAS session that is still running on the server. It sends the script back to the section that starts SAS through a TSO sign-on.

  20. 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 SAS log at the client and then abnormally ends the script processing as well as the SIGNON.

Previous Page | Next Page | Top of Page