[Xymon] xymon, xymon-rclient and md5sum checks

Jeremy Laidman jlaidman at rebel-it.com.au
Wed Jun 10 00:29:46 CEST 2015


On 10 June 2015 at 06:28, oliver <ohemming at gmail.com> wrote:

> On Tue, Jun 9, 2015 at 3:55 PM, Root, Paul T <Paul.Root at centurylink.com>
> wrote:
> > The solution would be more like:
> > echo "if [ \"$FILENAME\" != \"\" -a -e \"$FILENAME\" ]; then"
>
> Thanks - makes more sense now but I think you added an errant -e in
> that solution :-)


Yes, and no.  The "-e" for "exists" is a required test.  The fact that it
isn't supported as such on Solaris Bourne shell (sh) means that we need an
alternative.  The solution you proposed is to effectively not test for the
file's existence, meaning that if the file exists, no problem, but if the
file doesn't exist, error and unknown consequences.

Paul's solution was attempting to solve a perceived problem about Solaris
Bourne shell's ability to test whether a string is non-empty, and I'm
guessing he thought that was the cause of the error.  But it's not.

A workable solution is to substitute "-f" for "-e".  The difference between
"-f" and "-e" is that "-f" tests for a file that exists AND is a regular
file.  In our situation, it's going to be rare that we would want a Xymon
file test on a non-file (socket, pipe, device) and so for our purposes,
"-f" is a suitable replacement.  Other alternatives that might be suitable
are "-r" (exists and is readable) or "-s" (exists and has size >0) but I
can imagine cases where these might not fit requirements, so "-f" is
probably the most useful alternative.

So the following should work:

echo "if [ \"$FILENAME\" -a -f \"$FILENAME\" ]; then"

Thanks for the bug report.  I'll update the version on my site in the next
day or so.

Cheers
Jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20150610/d0d71659/attachment.html>


More information about the Xymon mailing list