Fwd: Alarm Program Question
Posted in 2009
Curtis: Using '==' in ksh comparisons was supported officially by David Korn for many years until it was deprecated in favor of '=' several years ago in order to improve compatibility with the IEEE POSIX 1003.2 Shell and Utilities Language Committee standard. Indeed the doubled equals operator for comparison is still supported on all platforms and versions of ksh that I am aware of except the one that is delivered with AIX - which is why I know about the change since bunches of scripts that worked fine on Solaris, HPUX, and Linux stopped working when we ported them to AIX. So the code is not a mistake, just written by an old-timer like me who doesn't remember all the time that '==' has been deprecated. It works, no just be serendipity, but because you are on one of the platforms that still supports the older construct - obviously not AIX. Yes, bash does not support '==' but then bash also does not support 'typeset -u' and several other ksh constructs which all ksh versions do support and the semantics of 'read' in bash are different from ksh as well. Comparing ksh to bash is irrelevant as the script specifies '#!/usr/bin/ksh' or '#!/bin/ksh' at the top depending on platform. As to that block of code, it is saying: IF ALARMPROGRAMTEST IS SET DO NOT ATTEMPT TO SEND EMAILS JUST WRITE THE EMAIL TEXT TO THE FILE NAMED IN ALARMTESTFILE. This is an artifact of IBM/Informix code testing that was left in there so that you/we could enable the 'test mode' and test various alarms without inundating all of the registered email recipients with test messages. So, bottom line, the alarmprogram.sh code isn't 'crap'. However, you are not required to use it, it's there as an example of what to do. You can write your own or you can download my package utils3_ak which contains my program eventalarm.c which is a fully functional executable ALARMPROGRAM. Art Art S. Kagel Oninit (www.oninit.com) IIUG Board of Directors (art@iiug.org) Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Oninit, the IIUG, nor any other organization with which I am associated either explicitly or implicitly. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Thu, Sep 3, 2009 at 10:43 AM, bozon <curtis@crowson1.com> wrote: > 11.50FC3 question > > I am upgrading to the new alarmprogram.sh with 11.50FC3. I was looking > at the script and I came across this LINE: > > ALARMTESTFILE= > > Yes it sets the variable to nothing and it isn't in the PUBLIC section > to be set by us. > It is only used in one other place. > > if ( `test x${MAILTO} != x` ) then > printf "\\n" >> $MAILHEAD > cat $MAILBODY >> $MAILHEAD > if ( `test x${ALARMPROGRAMTEST} = x` ) then > if ( `test x${MAILUTILITY} != x` ) then > ## Do not send same alarm in less than 5 minute interval. > if ( test `grep "$EVENT_MSG" $LASTALARMFILE|wc -l` -lt 1 ) then > $MAILUTILITY $MAILTO < $MAILHEAD > fi > else > echo "MAILUTILITY is not set, NO MAIL will be sent." > fi > else > cat $MAILHEAD >> $ALARMTESTFILE > fi > else > echo "SENDER IS NULL NO MAIL WILL BE SENT" > fi > > So, basically I want to know WTF? Is this just crap that doesn't > really work but doesn't hurt you because it isn't really used anymore. > I am reticent to use the alarmprogram.sh because I find things like: > > if ( `test x${LTAPEDEV} == x/dev/null` ) then > > There is no such thing as == in the ksh test command (At least > according to my old ksh O'Reily book). I looked it up to be sure. The > rest of the test command use the proper "=" operator for string > compare. Of course, because of some fluke it does seem to return what > you would expect test xA == xA returns 0 test xA == xB returns 1 (in > bash anyway I don't have a real version of ksh to try it on. > > Mistakes like these just worry me that someone spent very little time > with this script. I could write a better script but I shouldn't have > to. > > _______________________________________________ > Informix-list mailing list > Informix-list@iiug.org > http://www.iiug.org/mailman/listinfo/informix-list >