ssh remote command
nmeyers at javalinux.net
nmeyers at javalinux.net
Wed Oct 25 11:50:12 EDT 2006
On Wed, Oct 25, 2006 at 11:31:17AM -0400, Paul Baumgardner wrote:
> I'm trying to slurp some data out of a log file via ssh and I'm
> getting different results from ssh and doing it on the localhost.
> Both results are fine, though I'm curious as to why the output via ssh
> is different.
In the ssh case, the $2 is inside double-quotes, so it's being
interpolated by your shell on server1 - probably as an empty string,
so the awk command you're sending is {print }. You could escape the $,
or switch quote style in the middle, like this:
ssh server2 "grep 'ORA-' /var/log/core.log | awk '{print "'$2'"}' | sort | uniq -c | sort -rn"
What I'm doing is ending the double-quote, starting a single-quote,
then ending that and returning to double-quote.
That's three quotes. In the words of Groucho Marx: "add one more and
you'll have a gallon."
Nathan
>
>
> [paul at server1 ~]$ ssh server2 "grep 'ORA-' /var/log/core.log | awk
> '{print $2}' | sort | uniq -c | sort -rn"
> 26 java.sql.SQLException: ORA-00001: unique constraint
> (SPRINT_CAMPAIGN.MO_C_USER_INTEREST_ENTRY_1) violated
> 18 java.sql.SQLException: ORA-00001: unique constraint
> (SPRINT_CAMPAIGN.MO_C_USER_INFO_1) violated [newbury at monitor ~]$
>
> On the local host:
>
> [paul at server2 ~]$ sudo grep 'ORA-' /var/log/core.log | awk '{print
> $2}' | sort | uniq -c | sort -rn
> 44 ORA-00001:
> [paulr at server2 ~]
>
> Anyone have any ideas? Is it something to do with the quotes in the
> command over ssh?
>
> Thanks,
> Paul
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://olduvai.blu.org/mailman/listinfo/discuss
>
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the Discuss
mailing list