tobold.org

correct • elegant • free

△ comp.unix.shell △

◅ Help, I want to do baaaad things :-)

Shell script help ▻

Better cron output handling?

In article <p7aF4.6$NT5.1560@news.callamer.com>,
Dave Carmean <dlc@acctsrv01.halibut.com> wrote:
>: Have your script copy stdin to a temporary file, and then test whether the
>: file is empty, i.e. something like:
>
>I didn't really want to do that.  Here's what I came up with:

Which reads the entire input into memory instead.  Your call, but I've
seen enough cron jobs which normally print a couple of lines, but
sometimes go crazy and spew out thousands, that I'd rather use a
temporary file.

Anyway,

>   ORIG_IFS=$IFS
>   IFS=''
>   input=`cat -`

That's (Bing!) a UUOHATC.  (Useless Use Of Hyphen Argument To Cat, of
course.)  Some people find comfort in `cat -', but in fact it just means
the same as a bare `cat'.

>   if [ $input ]

I think you'll find

    if [ -n "$input" ]

works for rather more values of input.

Tim.
--
Tim Goodwin   | "If you don't know what closures are, you probably don't
Leicester, UK | want to know what closures are." -- Larry Wall

Original headers:

From: tjg@star.le.ac.uk (Tim Goodwin)
Newsgroups: comp.unix.shell,comp.unix.admin
Subject: Re: Better cron output handling?
Date: 3 Apr 2000 12:54:58 +0100
Message-ID: <8ca0r8$gbr$1@ltpcg.star.le.ac.uk>
References: <k1PE4.4$Z%4.1827@news.callamer.com>
  <j1RE4.39$YN6.1541@burlma1-snr2> <p7aF4.6$NT5.1560@news.callamer.com>

△ comp.unix.shell △

◅ Help, I want to do baaaad things :-)

Shell script help ▻