Hello jo19021,
as your box is in Unix, you have 1000 ways to do the same thing :-D All depending on how you want to do it done!
Your solution is good. For me it's not so good, because you need to hardcode the password of CMOD in your script.
My suggestion was simply you could use the fact that each time CMOD wants to log something in the "System Log", it calls the "arslog" command.
This arslog is a simple shell script which can help the admin to fetch the message before it sends it to "System Log". And do something useful for you.
For example:
#!/bin/ksh
# $1 - OnDemand Instance Name
# $2 - Time Stamp
# $3 - Log Identifier
# $4 - Userid
# $5 - Account
# $6 - Severity
# $7 - Message Number
# $8 - Message Text
if [[ $7 -eq 88 ]]; then
mail -s "CMOD: Error while archiving ($1)" <some e-mail> << EOF
$@
EOF
fi
It means you will receive one e-mail per error... which could be not what you want.
But it could be usefull to gather all messages somewhere, and then sends it to you. In that way, you don't need to write the password in your script!
For example:
#!/bin/ksh
# $1 - OnDemand Instance Name
# $2 - Time Stamp
# $3 - Log Identifier
# $4 - Userid
# $5 - Account
# $6 - Severity
# $7 - Message Number
# $8 - Message Text
if [[ $7 -eq 88 ]]; then
print "Instance: $1\tTimestamp: $2\tLog ID: $3\tUser ID: $4\tAccount: $5\tMessage Text: $8" >> /home/ccsuser/$(date +%Y%j)loadcheck.txt
fi
And you have another one which will get the file and send to you, which will put in the crontab, or any scheduler of your choice.
#!/bin/ksh
# Depending on the UNIX search the correct PATH for arsdate
if [[ -f /usr/lpp/ars/bin/arsdate ]]; then
# AIX Path
ARSDATE=/usr/lpp/ars/bin/arsdate
else
# All other Unix (Linux, Sun, HP, ...)
ARSDATE=/opt/ondemand/bin/arsdate
fi
LOGDATE=$1
if [[ -z "${LOGDATE}" ]]; then
# If no date given, I will take the date of yesterday
LOGDATE=$($ARSDATE -g -d -1 -f %Y%j | cut -f2)
fi
LOGFILE=/home/ccsuser/${LOGDATE}loadcheck.txt
if [[ ! -s ${LOGFILE} ]]
then
mail -s "All Loads ran fine" <email address> < /dev/null
else
/opt/SAscripts/bin/uuencode ${LOGFILE} ${LOGFILE##*/} | mailx -s "A load job failed on PG & Oil Prod" <email address>
fi
Of course, you need to put the code in your crontab for the day after (meaning today you receive the errors from yesterday, etc...) in this example.
As you can see no password, nowhere... so it means you don't have to remember to change the password in the script. In addition, no one can guess what is the admin password for example!!
I don't know if it can help you, or give you some ideas.
This is something I would do.
Or you could also do, like I do for lots of customer, create your own archiving scripts (which use arsload at the end), and get the errors directly by checking if arsload was correctly executed, if not... then write the error somewhere.
But again, your solution is good, but it is not how I would have done it
And it is ok like that too !!
Cheers,
Alessandro