<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need help with ssh to multiple hosts with pipe in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883219#M638875</link>
    <description>&lt;P&gt;&amp;gt;which is NOT working, the way I want it to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How is it failing?&lt;/P&gt;&lt;P&gt;for i in $(&amp;lt; /tmp/list); do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; echo "-------------------$i----------------"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ssh $i "lsof | grep db | grep EST| awk '{print $2}' | sort | uniq | while read i ; do ps -ef | grep $i; done"&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can think of one thing.&amp;nbsp; The "grep $i" is expanded from the outer for loop variable.&amp;nbsp; Better to use different descriptive names and also quote the remote variable:&amp;nbsp; (And don't put it all on one&amp;nbsp; line.&amp;nbsp; :-)&amp;nbsp; Test it first though.&lt;/P&gt;&lt;P&gt;for node in $(&amp;lt; /tmp/list); do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; echo "-------------------$node----------------"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ssh $node "lsof | grep db | grep EST | awk '{print $2}' | sort -u |&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while read file; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ps -ef | grep \$file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; done"&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;</description>
    <pubDate>Thu, 29 Nov 2012 06:59:04 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2012-11-29T06:59:04Z</dc:date>
    <item>
      <title>Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883211#M638874</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following command which is NOT working, the way I want it to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The intention is to ssh to a list of servers from an admin box and issue a command against a list of PID and find out the name of the PID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;for i in `cat /tmp/list`; do echo "-------------------$i----------------" ; ssh $i "lsof |grep db|grep EST|awk '{print $2}'|sort|uniq | while read i ;do ps -ef|grep $i;done " ; done &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Allan.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2012 06:44:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883211#M638874</guid>
      <dc:creator>allanm77</dc:creator>
      <dc:date>2012-11-29T06:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883219#M638875</link>
      <description>&lt;P&gt;&amp;gt;which is NOT working, the way I want it to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How is it failing?&lt;/P&gt;&lt;P&gt;for i in $(&amp;lt; /tmp/list); do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; echo "-------------------$i----------------"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ssh $i "lsof | grep db | grep EST| awk '{print $2}' | sort | uniq | while read i ; do ps -ef | grep $i; done"&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can think of one thing.&amp;nbsp; The "grep $i" is expanded from the outer for loop variable.&amp;nbsp; Better to use different descriptive names and also quote the remote variable:&amp;nbsp; (And don't put it all on one&amp;nbsp; line.&amp;nbsp; :-)&amp;nbsp; Test it first though.&lt;/P&gt;&lt;P&gt;for node in $(&amp;lt; /tmp/list); do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; echo "-------------------$node----------------"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ssh $node "lsof | grep db | grep EST | awk '{print $2}' | sort -u |&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while read file; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ps -ef | grep \$file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; done"&lt;/P&gt;&lt;P&gt;done&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2012 06:59:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883219#M638875</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-11-29T06:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883255#M638876</link>
      <description>Thanks Dennis, but I am getting:-&lt;BR /&gt;&lt;BR /&gt;Invalid null command.&lt;BR /&gt;while: Expression Syntax.&lt;BR /&gt;Usage: grep [OPTION]... PATTERN [FILE]...&lt;BR /&gt;Try `grep --help' for more information.&lt;BR /&gt;done: Command not found.</description>
      <pubDate>Thu, 29 Nov 2012 07:44:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883255#M638876</guid>
      <dc:creator>allanm77</dc:creator>
      <dc:date>2012-11-29T07:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883257#M638877</link>
      <description>Is there a way to make it work using xargs instead of while ?</description>
      <pubDate>Thu, 29 Nov 2012 07:45:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883257#M638877</guid>
      <dc:creator>allanm77</dc:creator>
      <dc:date>2012-11-29T07:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883291#M638878</link>
      <description>&lt;P&gt;&amp;gt;but I am getting: Invalid null command.&amp;nbsp; while: Expression Syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ah, one more "$" to quote:&lt;/P&gt;&lt;P&gt;awk '{print \$2}' | sort -u |&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;Is there a way to make it work using xargs instead of while?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why bother?&amp;nbsp; Use vector methods:&lt;/P&gt;&lt;P&gt;ssh $node "lsof | grep db | grep EST | awk '{print $2}' | sort -u &amp;gt; /var/tmp/fflist.\$\$;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ps -ef | grep -f /var/tmp/fflist.\$\$; rm -f /var/tmp/fflist.\$\$"&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2012 08:37:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883291#M638878</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-11-29T08:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883329#M638879</link>
      <description>Problem is that other machines have a different shell than what I am using on the admin box and its not accepting while loop.&lt;BR /&gt;&lt;BR /&gt;The other boxes have t-csh.</description>
      <pubDate>Thu, 29 Nov 2012 08:39:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883329#M638879</guid>
      <dc:creator>allanm77</dc:creator>
      <dc:date>2012-11-29T08:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883331#M638880</link>
      <description>tried giving ssh $i "bash|lsof ... " didnt work.</description>
      <pubDate>Thu, 29 Nov 2012 08:41:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883331#M638880</guid>
      <dc:creator>allanm77</dc:creator>
      <dc:date>2012-11-29T08:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883591#M638881</link>
      <description>&lt;P&gt;&amp;gt;The other boxes have t-csh.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any reason you are using a real shell and trying to talk to machines with scummy C shell?&amp;nbsp; ;-)&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;gt;tried giving ssh $node "bash | lsof ... " didn't work.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;You need either:&lt;/DIV&gt;&lt;DIV&gt;1) bash -c "lsof ... "&amp;nbsp; Which play havoc with your existing quotes and quoted "$".&lt;/DIV&gt;&lt;DIV&gt;2) echo "lsof ..." | bash&lt;/DIV&gt;&lt;DIV&gt;3) Or a here doc variant of 2).&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 29 Nov 2012 11:52:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5883591#M638881</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-11-29T11:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884297#M638882</link>
      <description>Thanks for your continued support , i tried #2 and getting -&lt;BR /&gt;&lt;BR /&gt;while: Expression Syntax.&lt;BR /&gt;bash: line 1: 1: command not found&lt;BR /&gt;&lt;BR /&gt;also, #1 is also not working as expected.&lt;BR /&gt;&lt;BR /&gt;Is there room for xargs?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Nov 2012 18:22:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884297#M638882</guid>
      <dc:creator>allanm77</dc:creator>
      <dc:date>2012-11-29T18:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884309#M638883</link>
      <description>&lt;P&gt;&amp;gt;I tried #2 and getting - also, #1 is also not working as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately I no longer know exactly what you have, please provide examples.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;Is there room for xargs?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you tried my vector method with grep -f?&amp;nbsp; No loops there, just an extra temp file to clean up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2012 18:33:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884309#M638883</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-11-29T18:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884365#M638884</link>
      <description>The vector method seems to be working when I actually run it by sshing into the box but remote from admin box it return no output.&lt;BR /&gt;&lt;BR /&gt;Thought?</description>
      <pubDate>Thu, 29 Nov 2012 19:12:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884365#M638884</guid>
      <dc:creator>allanm77</dc:creator>
      <dc:date>2012-11-29T19:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884421#M638885</link>
      <description>The existing issue is with awk '{print $2}' not working with the remote ssh.</description>
      <pubDate>Thu, 29 Nov 2012 20:19:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884421#M638885</guid>
      <dc:creator>allanm77</dc:creator>
      <dc:date>2012-11-29T20:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884429#M638886</link>
      <description>Its working now after escaping the \$2.&lt;BR /&gt;&lt;BR /&gt;Thanks so much for the vector method!</description>
      <pubDate>Thu, 29 Nov 2012 20:24:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884429#M638886</guid>
      <dc:creator>allanm77</dc:creator>
      <dc:date>2012-11-29T20:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with ssh to multiple hosts with pipe</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884983#M638887</link>
      <description>&lt;P&gt;&amp;gt;Thanks so much for the vector method!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would be nice if you would assign some kudos.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2012 04:02:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-with-ssh-to-multiple-hosts-with-pipe/m-p/5884983#M638887</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-11-30T04:02:59Z</dc:date>
    </item>
  </channel>
</rss>

