[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] bash script problem
- Subject: [ale] bash script problem
- From: jimpop at yahoo.com (Jim Popovitch)
- Date: Fri, 15 Dec 2006 13:59:16 -0500
- In-reply-to: <[email protected]>
- References: <1166207427.19125.7.camel@localhost> <[email protected]>
On Fri, 2006-12-15 at 13:43 -0500, Charles Shapiro wrote:
> Isn't "if" a bash built-in? If so, I'd expect:
>
> CMD="/bin/bash -c 'if [ -e /var/lib/clamav/daily.cvd ]; then ls
> -al /var/lib/clamav/daily.cvd; else echo; fi' "
>
> would work better.
>
Thanks for the suggestion Charles, however that still doesn't work. CMD
now looks like this:
CMD="/bin/bash -c 'if [ -e /var/lib/clamav/daily.cvd ]; then
ls -al /var/lib/clamav/daily.cvd; else echo; fi'"
and the new errors are:
[: -c: line 1: unexpected EOF while looking for matching `''
[: -c: line 2: syntax error: unexpected end of file
Any other suggestions?
Thanks,
-Jim P.
> -- CHS
>
>
>
> On 12/15/06, Jim Popovitch <jimpop at yahoo.com> wrote:
> Below is a small script that i use to check the status of
> ClamAV's
> daily.cvd file on a bunch of servers. This works for all
> remote servers
> listed in ~/.hosts, but if the host equals `hostname` the
> command fails
> to execute with the error "line 1: if: command not
> found". Now, if I
> remove the "if ..." logic in CMD and replace it just with "ls
> -al ...."
> then the command succeeds for all hosts including the local
> machine it
> is run on. Any ideas on why the "if" fails?
>
> --------------------
> #!/bin/sh
>
> CMD="if [ -e /var/lib/clamav/daily.cvd ]; then ls
> -al /var/lib/clamav/daily.cvd; else echo; fi"
>
> me=`hostname`
>
> for host in `cat ~/.hosts`; do
> echo -n "$host ";
> if [ $host = $me ]; then
> `$CMD`;
> else
> ssh $host $CMD;
> fi
> done
> ---------------------
>
> Thanks,
>
> -Jim P.
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale