On Wednesday, July 21, 2010 01:10:50 pm John Hein did opine:
> Gene Heskett wrote at 12:04 -0400 on Jul 21, 2010:
> > Greetings all;
> >
> > My catchup script seems to be working with 2 exceptions, first being
> > that I am not getting any emails from it, so I installed dnsmasq to
> > see if that fixes that.
> >
> > 2nd, each pass through my catchup script loop elicits an error
> > warning from the main script:
> >
> > ./flush.sh: line 173: [: !=: unary operator expected
> >
> > from that script:
> > # or are we running as flush.sh
> >
> > if [ $0 == "./flush.sh" ] || [ $0 == "${MYDIR}/flush.sh" ] || [ $0 ==
> > "flush.sh" ]; then
>
> == is a bash-ism. Get in the habit of using = for posix compliance.
> You'll thank yourself when you might have to run a script on a system
> that doesn't use bash for sh(1) (bsd's, solaris).
>
> "Always" put quotes around vars ("$foo", "$0", etc.) since vars
> can contain strings with spaces confusing test(1) (aka [).
>
> You don't need quotes around literals that you have written
> ("./flush.sh" in your case above). So in '[ $0 == "./flush.sh" ]',
> you have your quoting backwards (with respect to defensive script
> writing).
>
> > # we don't want amflush to disconnect or ask questions
> > if [ `/bin/ls /dumps` != "" ] ; then
> > <-------------------line 173
> >
> > echo "Backup script running amflush -bf $CONFIGNAME "
> > |tee -
> >
> > a >> $LOG
>
> Same deal (use quotes) for back-tick expressions (`cmd` or $(cmd)).
> And that's your problem. Looks like `ls /dumps` is providing empty
> output.
>
And that is all I care about, is whether or not its a null\r return. If
its an empty return, then there is no need to do the flush operation.
I'll give the "" a shot for grins, thanks. And I'll reread the bash docs
too.
> example:
>
> if [ `echo 1 2` = 1 ]; then echo y; else echo n; fi
> [: 1: unexpected operator
>
> or
>
> bash -c 'if [ `echo -n` != "" ]; then echo y; else echo n; fi'
> bash: [: !=: unary operator expected
>
>
> if [ "`echo 1 2`" = 1 ]; then echo y; else echo n; fi
> n
--
Cheers, Gene
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
When asked by an anthropologist what the Indians called America before
the white men came, an Indian said simply "Ours."
-- Vine Deloria, Jr.