Hi , all :

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

The shell test script is like this :



   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


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.
   3. _CMD="ssh root@localhost"
   4.
   5. cpu_num="$($_CMD  << 'HERE'
   6. awk '/processor/{count["proc"]++}; END{print count["proc"]}'
   /proc/cpuinfo
   7. HERE
   8.
   9. )“
   10.
   11. echo $cpu_num
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos

Reply via email to