Supress Error Message

David C Lawrence tale at pawl.rpi.edu
Fri Nov 24 09:26:49 AEST 1989


In <52 at fleet.UUCP> mel at fleet.UUCP (mel) writes:
Mel> #! /bin/csh
Mel> foreach i (rex cbay)
Mel>     foreach j (/usr/spool/uucp/$i/C.$i*)
Mel>         if (-e $j) then
Mel>             /usr/lib/uucp/uucico -r1 -s$i
Mel>         endif
Mel>         break
Mel>     end
Mel> end

Mel> The above script is triggered by the following line in my root cron file.
Mel> 0,15,30,45  * * * *     csh /usr/lib/uucp/uucall >/dev/null

Why are you doing it this way?  Does your XENIX not understand #! execution?
If it does you shouldn't need the "csh".

Mel> foreach: No match.

Yeah.  C Shell globbing does that to you.

Mel> HOW CAN I ALTER THIS SCRIPT TO AVOID THE SENDING OF THIS MESSAGE FOR BOTH
Mel> OF THE TWO CASES STATED ABOVE?

A FEW DIFFERENT WAYS.  Oops, looks like the ol' caps lock got stuck.

You could rewrite it in sh; pretty trivial for this.  In fact, just
change everything to the equivalent Bourne shell syntax and your
problem goes away:

#! /bin/sh
for i in rex cbay; do
  for j in /usr/spool/uucp/$i/C.$i*; do
    if [ -s $j ]; then # okay, okay.  not really same as -e
      /usr/lib/uucp/uucico -r1 -s$i
      break 2  # okay, so i moved the break too.  Why was a foreach even used?
    fi
  done
done

But that's more a political statement against csh than anything else,
so just "set nonomatch" at the head of your csh script and the same
sort of processing would occur.

If you want to just bag any error messages that ever might happen, you
could redirect stderr from the cron invocation, too.

You could also use find(1) to avoid globbing complaints; take out the
foreach j and replace it with:

  if [ "`find /usr/spool/uucp/$i -name \"C.$i*\" -print`" ]; then
     uucico ...
  fi

There are probably at least four or five other ways to work this out,
including a perl solution from Randall, soon to be appearing in a
comp.unix.* group near you.

Dave
-- 
 (setq mail '("tale at pawl.rpi.edu" "tale at ai.mit.edu" "tale at rpitsmts.bitnet"))



More information about the Comp.unix.questions mailing list