Hi all:
I'm doing an audit of some Linux machines, and have used this awk one-liner to find accounts with uid > 499:
awk -F: '{if ($3 > 499) print $0}' < /etc/passwd
It works great if you run it on a host directly, but if I try to ssh to a remote host and run the command it fails:
mybox$ ssh servername awk -F: '{if ($3 > 499) print $0}' < /etc/passwd
bash: -c: line 1: syntax error near unexpected token `(' bash: -c: line 1: `awk -F: {if ($3 > 499) print $0}'
I tried wrapping the command in quotes but no luck. Any suggestions? I want to put this into a for loop so I can grab the info from multiple machines.
thanks
Sean
On Thu, 2008-02-28 at 02:56 -0600, Sean Carolan wrote:
Hi all:
I'm doing an audit of some Linux machines, and have used this awk one-liner to find accounts with uid > 499:
awk -F: '{if ($3 > 499) print $0}' < /etc/passwd
It works great if you run it on a host directly, but if I try to ssh to a remote host and run the command it fails:
mybox$ ssh servername awk -F: '{if ($3 > 499) print $0}' < /etc/passwd
bash: -c: line 1: syntax error near unexpected token `(' bash: -c: line 1: `awk -F: {if ($3 > 499) print $0}'
I tried wrapping the command in quotes but no luck. Any suggestions? I want to put this into a for loop so I can grab the info from multiple machines.
ssh servername awk -F: "'{if ($3 > 499) print $0}'" < /etc/passwd
thanks
Sean
<snip sig stuff>
On Thu, 2008-02-28 at 04:27 -0500, William L. Maltby wrote:
On Thu, 2008-02-28 at 02:56 -0600, Sean Carolan wrote:
Hi all:
I'm doing an audit of some Linux machines, and have used this awk one-liner to find accounts with uid > 499:
awk -F: '{if ($3 > 499) print $0}' < /etc/passwd
It works great if you run it on a host directly, but if I try to ssh to a remote host and run the command it fails:
ssh servername awk -F: "'{if ($3 > 499) print $0}'" < /etc/passwd
ssh servername awk -F: "'{if ($3 > 499) print $0}' < /etc/passwd"
otherwise '< /etc/passwd' happens on the client.
Jim
On Thu, 2008-02-28 at 09:48 +0000, Jim Wight wrote:
On Thu, 2008-02-28 at 04:27 -0500, William L. Maltby wrote:
On Thu, 2008-02-28 at 02:56 -0600, Sean Carolan wrote:
Hi all:
I'm doing an audit of some Linux machines, and have used this awk one-liner to find accounts with uid > 499:
awk -F: '{if ($3 > 499) print $0}' < /etc/passwd
It works great if you run it on a host directly, but if I try to ssh to a remote host and run the command it fails:
ssh servername awk -F: "'{if ($3 > 499) print $0}'" < /etc/passwd
ssh servername awk -F: "'{if ($3 > 499) print $0}' < /etc/passwd"
otherwise '< /etc/passwd' happens on the client.
Jim
DRAT! Need to get first cup-o-java! I even remembered to watch out for this before I typed my reply!
Better idea: go back to bed!
<snip sig stuff>