Date: Mon, 16 Jul 2001 19:41:21 +0100
Reply-To: roland.rashleigh-berry@virgin.net
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Roland <roland.rashleigh-berry@VIRGIN.NET>
Organization: N/A
Subject: Unix script to scan SAS logs
Content-Type: text/plain; charset=us-ascii
Writing utility scripts is so easy once you know how. And if you don't
know how there will be Unix people on your site who can do them
blindfold. At the end is a no frills script to read your SAS logs and
pick out key messages.
But they have so many uses.
How about a script that will recover the program from its log?
A script to globally substitute one string for another in multiple sas
programs.
A script to search for a string in multiple files and display the found
line against the file name.
A script that will search a SAS library for a condition and print all
the results as in "printall subject=7654".
A script to check for empty files.
A script to check for .log files and .lst files without a corresponding
program file.
There is somebody in your organisation who can write each of these
utilities in about 5 minutes. You are limited only by your imagination
and knowing who to ask.
#!/bin/sh
# Scriptname: scanlogs
# Purpose: To scan SAS logs for important messages.
# Usage: scanlogs *.log (displays them on the screen)
# scanlogs *.log > scanlogs.log (writes them to a file)
while [ $# -gt 0 ]
do
awk '{if ( ( index($0,"ERROR") == 1 \
|| index($0,"WARNING") == 1 \
|| index($0,"MERGE statement") > 0 \
|| index($0,"W.D format") > 0 \
|| index($0,"truncated ") > 0 \
|| index($0," 0 observations and ") > 0 \
|| index($0,"outside the axis range") > 0 \
|| index($0,"uninitialized") > 0 ) \
&& index($0,"Errors printed on") == 0 \
&& index($0,"scheduled to expire on") == 0 \
&& index($0,"product with which") == 0 \
&& index($0,"representative to have") == 0 )
{printf "%-30s %-80s\n","'$1'",$0}}' $1
shift
done