ssh remote execute awk problem

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



Hi , all :


There is a problem on executing awk command to remote servers;

The shell test script is like this :


  1. #!/bin/sh

  2. _CMD="ssh root@localhost"

  3. cpu_num="$($_CMD awk '/processor/{count["proc"]++}; END{print count["proc"]}' /proc/cpuinfo)“

  4. echo $cpu_num

My root account can entry the server without the passwd.

But  I found no result on the screen .

Is there some error on that script ? By the way , I googled and found use the following method can run the right result .

  1. #!/bin/sh

  2. _CMD="ssh root@localhost"

  3. cpu_num="$($_CMD  << 'HERE'
  4. awk '/processor/{count["proc"]++}; END{print count["proc"]}' /proc/cpuinfo
  5. HERE

  6. )“

  7. echo $cpu_num








_______________________________________________
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