Script to pull uid greater than 1000 from remote server

Hello,

I am trying to get UID # greater than 1000 from all linux server, I tried this script getting this error message, someone please suggest.

$for i in `cat hostlist.0709.org` ; do ssh -t $i 'awk -F':' "{ if($3 >= 1000) print $0 }" /etc/passwd ' >> output ; done
$ cat output
hostname1
awk: { if( >= 1000) print bash }
awk:       ^ syntax error
$

Thanks,

Try:

if(\$3 >= 1000)

Create a file myscript.sh

awk -F':' '{ if($3 >= 1000) print $0 }' /etc/passwd

Then the loop script passes this (unchanged!) to the remote shell

while read i
do
 ssh -qx "$i" '/bin/sh' <myscript.sh
done <hostlist.0709.org >output

You can also enclose awk command in backquote as below.

 
for i in `cat hostlist.0709.org` ; do ssh -t $i `awk -F':' "{ if($3 >= 1000) print $0 }" /etc/passwd ` >> output ; done

That's nonsense|wrong: it would run the `awk command` locally then try to remotely run its output (as a command).