Date: Fri, 28 Jun 2002 06:00:32 -0700
Reply-To: Meredith Clark <clarkmeredith@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Meredith Clark <clarkmeredith@YAHOO.COM>
Subject: automated error checking in logs - NT
In-Reply-To: <5BAE9407.588EBAE5.00182771@aol.com>
Content-Type: text/plain; charset=us-ascii
Just wanted to share with the list a method I
developed for NT that runs immediately after the
application is finished. I specify an -altlog, which
cannot be opened until the session is finished, so the
shortcut in the icon points to a batch file whose
first line runs the application, while the second line
runs a second SAS session that checks for errors in
the log.
The error checking routing is generalized so it can be
used for checking any application's log file.
**********************************************
This is what the batch file looks like:
(The first one runs the app)
"C:\Program Files\SAS Institute\SAS\V8\SAS.EXE"
-CONFIG "q:\xxxx\cdascfgP.sas" -set rootdir
q:\xxxx\approot -set dataroot "/xxx/xxxx/clients" -set
appstate PROD -set apploc UNIX -set appusr HH -altlog
"c:\PrdUX.log" -awstitle MC-UX
(the second one runs the error-checking program
immediately after the app is exited)
"C:\Program Files\SAS Institute\SAS\V8\SAS.EXE"
-CONFIG "q:\utilities\emailcfg.cfg" -set lognm
"c:\PrdUX.log" -set appnm "Market Connect" -set super
"Meredith-HDS_Clark" -sysin
"q:\utilities\emailerr.sas"
******************************************************
The config file contains information about our email
system, this is the beginning of the file with its
customized lines:
/* Application error email config */
/*q:utilities/emailcfg.cfg */
/* june 26 2002 */
-emailsys SMTP
-emailhost 999.999.999.99
-emailport 25
-altlog "c:\emailerr.log"
-nosplash
-icon
***************************************************
/*************************************************/
/*jun 13 2002 meredith q:/utilities/emailerr.sas */
/*This sends an email to the user if */
/* specified words and phrases are found. */
/* This will be part of a batch file run on NT. */
/*The first */
/* job is running the app. Then when it is exited*/
/*this program */
/* will run to see if there are any errors. */
/*If there are, an */
/* email is sent to the user */
/* The following needs to be set in the */
/* config file: (specific to our system) */
/* (q:/utilities/emailcfg.cfg) */
/* -EMAILSYS SMTP */
/* -EMAILHOST 999.999.999.99 */
/* -EMAILPORT 25 */
/* The following needs to be set in the shortcut*/
/* (Market Connect is being used as an */
/* example) */
/* -set logn "c:\QUX82tst.log" */
/* (name of log file) */
/* -set appnm "Market Connect" */
/* (name of application) */
/* -set super "Meredith Clark */
/* (optional-name of supervisor to be */
/* notified. Note underscore.) */
/* jun 25 2002 meredith using em commands to */
/* only send the email */
/* when an error is encountered. */
/* jun 25 2002 meredith generalizing to be */
/* used with any app */
/************************************************/
options mlogic mprint symbolgen;
%let
emailid=%qsysfunc(translate(%sysget(COMMENT),'_','
'))/HDS/HDM/HHCorp; *user email id;
%let lognm=%sysget(lognm);
*application log;
%let appnm=%sysget(appnm);
*application name;
%let super=%sysget(super)/HDS/HDM/HHCorp; *cc to
supervisor;
*see if log exists;
data _null_;
*c will contain the current line of the log file being
read. Length statement doesnt work;
c='12345678901234567890123456789012345678901234567890123456789012345678901234567890';
lognm="tempfile";
rc=filename(lognm,"&lognm");
_msg_=sysmsg();
put rc= _msg_=;
if rc=0 and fexist(lognm) then do;
*read each line;
fileid=fopen(lognm);
if fileid>0 then
do while(fread(fileid)=0 and _MSCerr ne 1);
rc=fget(fileid,c,80);
c=upcase(c);
*look for errors;
filename mymail email ("&emailid")
subject="&appnm session error!";
file mymail;
if (index(c,'ERROR:') or index(c,'SYSTEM STOPPED
PROCESSING')
or index(c,'UNINITIALIZED'))
and (%length(%sysget(COMMENT)) ge 1) /*dont send
to group logon id*/
then do;
put "There was a problem with your latest
&appnm session.";
put "Please check your log at the following
location:";
put "&lognm";
put ' ';
put 'This is the first error message:';
put c=;
put ' ';
put '!EM_ATTACH!' "&lognm";
put ' ';
if %length(%sysget(super)) ge 1 then
put '!EM_CC!' "&super";
put '!EM_SEND!';
put '!EM_ABORT!';
_MSCerr=1;*dont look any more if an error
has been found;
stop;
end; *error encountered;
else do;
put '!EM_ABORT!';
end; *no error encountered;
end; *do while file can be read;
end; *log found;
rc=fclose(fileid);
*de-assign lognm fileref;
rc=filename(lognm);
run;
****************************************************
Meredith
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com