[ale] bash script problem
Charles Shapiro
hooterpincher at gmail.com
Fri Dec 15 14:08:48 EST 2006
Oh, wait, you're not missing it.
Like the man said.
-- CHS
On 12/15/06, timothy at meanor.net <timothy at meanor.net> wrote:
>
> Try getting rid of the backticks around $CMD.
>
> -Tim
>
> >>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
>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ale
mailing list