Re: ssh remote execute awk problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, Mar 17, 2011 at 6:58 AM, John Doe <jdmls@xxxxxxxxx> wrote:
> From: sync <jiannma@xxxxxxxxx>
>>There is a problem on executing awk command to remote servers;
>>    1. #!/bin/sh
>>    2.
>>    3. _CMD="ssh root@localhost"
>>    4.
>>    5. cpu_num="$($_CMD awk '/processor/{count["proc"]++}; END{print
>>count["proc"]}' /proc/cpuinfo)“
>>    6.
>>    7. echo $cpu_num
>
> Quote the whole command and backslash the command quotes...
> ssh root@localhost "awk '/processor/{count[\"proc\"]++}; END{print
> count[\"proc\"] } ' /proc/cpuinfo"
>
> JD

Or do the processing locally and stay away from proc nuttiness,
without mucking with ssh and awk.

     grep ^processor /proc/cpuinfo | wc -l

Or:

     ssh -l $TARGETUSER $TARGETHOST "[ -e /proc/cpuinfo ] -a grep
^processor | wc -l"
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux