www.sas.com > Service and Support > Technical Support
 
Technical Support SAS - The power to know(tm)
  TS Home | Intro to Services | News and Info | Contact TS | Site Map | FAQ | Feedback

  

/****************************************************************/
/* SAS SAMPLE LIBRARY */
/* */
/* NAME: MKSCRPT */
/* TITLE: CONNECT Customized Script Macro */
/* PRODUCT: SAS/CONNECT */
/* SYSTEM: */
/* KEYS: CONNECT MACRO */
/* PROCS: */
/* DATA: */
/* */
/* REF: */
/* MISC: 1. This macro will generate a customized script */
/* file to be used with SAS/CONNECT signon/signoff */
/* commands. The user must input a fully-qualified */
/* filename for the script. */
/* 2. The macro uses scripts supplied by SAS Institute */
/* as templates for the customized scripts. Users */
/* who have made extensive changes to the Institute-*/
/* supplied scripts to meet unique needs may be */
/* required to make similar changes to customized */
/* scripts. */
/* 3. Usage: MKSCRPT has one argument--target host. */
/* (Users are prompted for any other data needed.) */
/* Valid targets are mvs, cms, vms, unix, and os2. */
/* Example: %mkscrpt(unix) */
/****************************************************************/

%macro mkscrpt(host);
options nonotes;

/**************************************************/
/* these global macvars are used in the data step */
/* which writes the custom script. */
/**************************************************/
%global log delim prompt userid password access filename
sasverb raccess logoff;

/**************************************************/
/* Display a brief header. */
/**************************************************/
%put;
%put %str( )The MKSCRPT Macro will create a SAS/CONNECT script that;
%put has been customized to your specifications. You will be;
%put prompted for any information needed by the macro to create;
%put your custom script.;
%put ;
%put %str( ) After the custom script has been output, you may wish;
%put to edit it for any further requirements not covered by the;
%put MKSCRPT macro.;
%put;
%put;

/**************************************************/
/* Validate the target host. */
/**************************************************/
%if %upcase(&host) = MVS |
%upcase(&host) = CMS |
%upcase(&host) = UNIX |
%upcase(&host) = VMS |
%upcase(&host) = VAX |
%upcase(&host) = OS2 |
%upcase(&host) = OS %then %goto continue;
%goto badhost;

%continue:

/**************************************************/
/* Input local (source) side comamid and */
/* validate response. */
/**************************************************/
%put Enter the comamid (local side): ;
%input access;

%if %upcase(&access) = TELNET |
%upcase(&access) = TCP |
%upcase(&access) = EHLLAPI %then %goto continu2;
%goto badam;

%continu2:

/**************************************************/
/* Input the (fully-qualified) filename of the */
/* custom script. */
/**************************************************/
%put Enter the filename for the custom script:;
%input filename;

/**************************************************/
/* Input whether the user wants the script to */
/* automatically log on to the target host. */
/**************************************************/
%if %upcase(&access) eq EHLLAPI %then %do;
%put Do you want the script to log on the remote side? ;
%input autolog;
%let autolog=%upcase(&autolog);
%end;
%else %let autolog = Y;

%if &autolog = Y %then %do;
%put;
%put Please check the logon section of the custom script.;
%put The custom script "waits for" a standard session ;
%put banner that may not be in use by your site. You ;
%put may need to edit the first "waitfor" statement. ;
%put;
%end;

%put Do you want echo on? ;
%input echo;
%let echo=%upcase(&echo);
%put Do you want trace on? ;
%input trace;
%let trace=%upcase(&trace);

/**************************************************/
/* Use knowledge of target host to determine the */
/* standard system prompt. */
/* Use knowledge of target host and comamid to */
/* determine the "login prompt" and the */
/* system command line delimiter. */
/**************************************************/
%if %upcase(&host) = MVS | %upcase(&host) = OS %then %do;
%let prompt = READY;
%let logoff = logoff;
%if %upcase(&access) = TELNET %then %do;
%let log = IKJ56700A ENTER;
%let delim = CR;
%let raccess= rasync;
%end; /* if access */
%else %if %upcase(&access) = TCP %then %do;
%let log = IKJ56700A ENTER;
%let delim = LF;
%let raccess= tcp;
%end; /* if TCP */
%else %do;
%let log= Welcome to;
%let delim = ENTER;
%let raccess= pclink;
%end; /* else access pclink */
%end; /* if host mvs */

%else %if %upcase(&host) = CMS %then %do;
%let prompt = Ready;
%let logoff = logoff;
%if %upcase(&access) = TELNET |
%upcase(&access) = TCP %then %do;
%let delim = CR;
%let log = VM ;
%if %upcase(&access) = TCP %then %let raccess= tcp;
%else %let raccess= rasync;
%end; /* if access */
%else %do;
%let delim = ENTER;
%let log = Welcome to;
%let raccess= pclink;
%end; /* else access pclink */
%end; /* if host cms */

%else %if %upcase(&host) = VMS | %upcase(&host) = VAX %then %do;
%let logoff = logout;
%let prompt = $;
%let delim = CR;
%let log = Username:;
%if %upcase(&access) = TCP %then %let raccess= tcp;
%else %let raccess= rasync;
%end; /* if host vms */

%else %if %upcase(&host) = UNIX %then %do;
%let logoff = logout;
%let prompt = $;
%let delim = LF;
%let log = ogin:;
%if %upcase(&access) = TCP %then %let raccess= tcp;
%else %let raccess= rasync;
%end; /* if host unix */

%else %if %upcase(&host) = OS2 %then %do;
%let logoff = exit;
%let prompt = ] ;
%let delim = CR;
%let log = ogin:;
%if %upcase(&access) = TCP %then %let raccess= tcp;
%else %let raccess= rasync;
%end; /* if host OS2 */

%else %do;
%let logoff = logoff;
%let prompt = $;
%let delim = LF ;
%let log = ogin:;
%end;

/**************************************************/
/* Show the user the standard system prompt for */
/* the target host and allow the user to */
/* input a different value. */
/**************************************************/
%put Does your remote account use the standard prompt--&prompt--? ;
%input std;

%if %upcase(&std) = N | %upcase(&std) = NO %then %do;
%put Enter remote system prompt: ;
%input prompt;
%end;

/**************************************************/
/* Show the use the system prompt again. */
/**************************************************/
%put The prompt &prompt will be used. ;
%put ;
/**************************************************/
/* Show the user the default system command to */
/* invoke SAS and allow the use to input */
/* another value. */
/**************************************************/
%let sasverb=sas;
%if %upcase(&host) ne OS2 %then %do;
%put Does your remote host use --&sasverb-- to invoke SAS? ;
%input tverb;
%if %upcase(&tverb) = N | %upcase(&tverb) = NO %then %do;
%put Enter command your remote host uses to invoke SAS: ;
%input sasverb;
%end;
%put The command &sasverb will be used. ;
%put;
%end;

/**************************************************/
/* MKSCRPT will spawn a null datastep, which in */
/* turn will output the customized script file. */
/**************************************************/

data _null_;
file "&filename";

put;
put " /* Customized SAS/CONNECT Script */ ";
put;

%if &echo = Y | &echo = YES %then %do;
put "echo on;";
%end;

%if &trace = Y | &trace = YES %then %do;
put "trace on;";
%end;

put;
put "if not &access then goto x%substr(&access,1,3);" ;
put "if signoff then goto signoff;" ;
put;

%if &autolog = Y | &autolog= YES %then %do;
%if %upcase(&host) ne OS2 %then %do;
put "waitfor '&log' : logon, 60 seconds;";
put "log 'ERROR: Script didnot understand remote session banner.';";
put "abort;";
put;
put "logon:";
%end; /* if not os2 */
/**************************************************/
/* A script can either query a user for the */
/* userid/password or hard-code them directly */
/* into the file. Determine which choice this */
/* user prefers. */
/**************************************************/
%put Should the script query you for your userid/password? ;
%input query;
%let query=%upcase(&query);

%if &query = N | &query= NO %then %do;
%put;
/**************************************************/
/* Warn the user that the userid/password will */
/* be hard-coded into the script. */
/**************************************************/
%put Your userid/password will be hard-coded in the script.;
%put;
%if %upcase(&host) ne OS2 %then %do;
%put Please enter your userid: ;
%input userid;
%end; /* if not os2 */
%put Please enter your password: ;
%input password;

%if %upcase(&host) = CMS %then %do;
put " type &delim; ";
put " waitfor 1 second; ";
put " type 'l '; ";
%end;

put " type '&userid' &delim ;";
put " waitfor 'Password', 'PASSWORD', 'password', ";
put " 30 seconds : timeout;";
put " type '&password' &delim ;";
put;
%end; /* if query no */
%else %do;
/**************************************************/
/* The user wishes to be prompted for userid and */
/* password by the script. */
/**************************************************/
%if %upcase(&host) = CMS %then %do;
put " type &delim; ";
put " waitfor 1 second; ";
put " type 'l '; ";
%end;
%if %upcase(&host) ne OS2 %then %do;
put " input 'Userid?';";
put " type &delim;";
%end; /* if not os2 */
put " waitfor 'Password', 'PASSWORD' ";
put " , 'password' , 30 seconds : uidpwd;";
put " input nodisplay 'Password?';";
put " type &delim;";
put;
%end; /* else query yes */

%end; /* if autolog yes */

%if %upcase(&host) = UNIX %then %do;
put "label1: ";
%end;

put " waitfor '&prompt', ";

/**************************************************/
/* Many UNIX machines query the user for terminal*/
/* type. Allow for that possibility. */
/**************************************************/
%if %upcase(&host) = UNIX %then %do;
put " 'Enter terminal type' : unx_term, ";
%end;

put ' 30 seconds : uidpwd;';
put;

/**************************************************/
/* Use knowledge of the target host and comamid */
/* to write the SAS invocation command. */
/**************************************************/
%if %upcase(&host) = MVS | %upcase(&host) = OS %then %do;
put 'type "' "&sasverb options(" @@ ;
put "'dmr,comamid=&raccess,device=grlink')" '"' " &delim ;" ;
%end; /* if host mvs */

%else %if %upcase(&host) = CMS %then %do;
put ' type "' "&sasverb (" @@ ;
put "dmr comamid=&raccess device=grlink)" '"' " &delim ;" ;
%end; /* if host cms */

%else %if %upcase(&host) = UNIX %then %do;
put ' type "' "&sasverb " @@ ;
put "-dmr -comamid &raccess -device grlink" '"' " &delim ;" ;
%end; /* if host unix */

%else %if %upcase(&host) = VMS | %upcase(&host) = VAX %then %do;
put ' type "' "&sasverb" @@ ;
put "/dmr/comamid=&raccess/device=grlink" '"' " &delim ;";
%end; /* if host VMS */
%else %do;
%if %upcase(&host) eq OS2 %then %do;
put " type 'sasdmr -dmr -comamid tcp -device grlink' &delim ; " ;
%end;
%end;

put " waitfor '&prompt' : nosas";
put ' , 90 seconds : timeout';
put " , 'SESSION ESTABLISHED', 'PACKET', 'IN PROGRESS' ;";
put;
put "stop;";
put ///;

put "timeout:";
put " log 'ERROR: Timeout waiting for remote session response.';";
put " type '" "&logoff" "' &delim ;";
put " waitfor 3 seconds;";
put " abort;";
put;

put "uidpwd:";
put " log 'ERROR: Remote session did not respond after login.';";
put " log 'ERROR: You may have entered an invalid userid or password.';";
put " abort;";
put;

put "nosas:";
put " log 'ERROR: Did not get SAS software startup messages.';";
put " type '" "&logoff" "' &delim ;";
put " waitfor 3 seconds;";
put " abort;";
put;

put "x%substr(&access,1,3):";
put " log 'ERROR: Incorrect communications access method.';";
put " abort;";
put;

put "signoff:";
put " waitfor '&prompt', 30 seconds;";

/**************************************************/
/* Assume that, if the user wishes automatic */
/* logon, the user also wishes automatic */
/* logoff. */
/**************************************************/
%if &autolog = Y | &autolog= YES %then %do;
/**************************************************/
/* use appropriate logoff command */
/**************************************************/
put " type '" "&logoff" "' &delim ;";
put " waitfor 3 seconds;";
%end; /* if autolog yes */

%else %do;
put ;
put " log 'NOTE: Remote host session was not logged off.';";
put;
%end; /* if autolog no */

put " stop;";

/**************************************************/
/* Respond TTY if unix host queries for terminal */
/* type. */
/**************************************************/
%if %upcase(&host) = UNIX %then %do;
put "unx_term:";
put " type 'tty' LF; ";
put " goto label1; ";
%end;

run;
%goto exit;

/**************************************************/
/* Write an error message if user inputs a bad */
/* access method. */
/**************************************************/
%badam:
%if %upcase(&access) = DECNET |
%upcase(&access) = APPC %then %do;
%put;
%put The access method &access does not require a script.;
%put MKSCRPT will not attempt to create one.;
%put;
%end;
%else %do;
%put;
%put The access method &access is not acceptable.;
%put Valid choices are telnet, tcp, and ehllapi.;
%put Please select one of these and try again.;
%put;
%end;
%goto exit;

/**************************************************/
/* Write an error message if user inputs a bad */
/* target host. */
/**************************************************/
%badhost:
%put;
%put The host &host is not acceptable.;
%put Valid choices are MVS, CMS, VMS, UNIX, and OS2.;
%put Please select one of these and try again.;
%put;

%exit:
%put;
%put **** MKSCRPT processing complete! ****;
%put;
options notes;
%mend mkscrpt;

Copyright (c) 2002 SAS Institute Inc. All Rights Reserved.
Terms of Use & Legal Information | Privacy Statement