<?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: while loop not working with remsh in a bourne shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428391#M2139</link>
    <description>Your problem is the line:&lt;BR /&gt;remsh 123.45.678.999 kill -9 $pid &lt;BR /&gt;&lt;BR /&gt;You need to use:&lt;BR /&gt;remsh 123.45.678.999 -n kill -9 $pid &lt;BR /&gt;&lt;BR /&gt;As it now stands, the first time the line is run, it sucks up all the remaining pid lines and sends them to the remote kill process which ignores them.</description>
    <pubDate>Thu, 29 Jun 2000 16:41:03 GMT</pubDate>
    <dc:creator>Paul Hite</dc:creator>
    <dc:date>2000-06-29T16:41:03Z</dc:date>
    <item>
      <title>while loop not working with remsh in a bourne shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428389#M2137</link>
      <description>I wrote a script similar to the following one that root would run to remotely kill the processes owned by user, tester:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;remsh 123.45.678.999 ps -ef | grep -v tester | grep -v grep | awk '{print $2}' |&lt;BR /&gt;while read pid&lt;BR /&gt;do&lt;BR /&gt;        remsh 123.45.678.999 kill -9 $pid&lt;BR /&gt;done&lt;BR /&gt;# end of script&lt;BR /&gt;&lt;BR /&gt;Well, it only kills the first process found, i.e. it appears that after it does the first remote kill it exits the while loop although there are other processes listed for $pid.&lt;BR /&gt;&lt;BR /&gt;The "local" version of the script works:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;ps -ef | grep -v tester | grep -v grep | awk '{print $2}' |&lt;BR /&gt;while read pid&lt;BR /&gt;do&lt;BR /&gt;        kill -9 $pid&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Any ideas why the `remsh` is causing/allowing the script to loop only once?&lt;BR /&gt;&lt;BR /&gt;thanks</description>
      <pubDate>Thu, 29 Jun 2000 15:44:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428389#M2137</guid>
      <dc:creator>Boyd Kodama</dc:creator>
      <dc:date>2000-06-29T15:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: while loop not working with remsh in a bourne shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428390#M2138</link>
      <description>The easy workaround to this behavior is to have the actual script reside in an executable file on the remote machine and then inkove it with remsh.</description>
      <pubDate>Thu, 29 Jun 2000 16:38:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428390#M2138</guid>
      <dc:creator>Tim Malnati</dc:creator>
      <dc:date>2000-06-29T16:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: while loop not working with remsh in a bourne shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428391#M2139</link>
      <description>Your problem is the line:&lt;BR /&gt;remsh 123.45.678.999 kill -9 $pid &lt;BR /&gt;&lt;BR /&gt;You need to use:&lt;BR /&gt;remsh 123.45.678.999 -n kill -9 $pid &lt;BR /&gt;&lt;BR /&gt;As it now stands, the first time the line is run, it sucks up all the remaining pid lines and sends them to the remote kill process which ignores them.</description>
      <pubDate>Thu, 29 Jun 2000 16:41:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428391#M2139</guid>
      <dc:creator>Paul Hite</dc:creator>
      <dc:date>2000-06-29T16:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: while loop not working with remsh in a bourne shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428392#M2140</link>
      <description>Boyd,&lt;BR /&gt;&lt;BR /&gt;the remsh -n simply redirects stdin from /dev/null.&lt;BR /&gt;&lt;BR /&gt;You'll need to use the following format:&lt;BR /&gt;&lt;BR /&gt;resmh &lt;IP address=""&gt; -n -c "kill -9 $pid"&lt;BR /&gt;&lt;BR /&gt;This will work.&lt;BR /&gt;&lt;BR /&gt;&lt;/IP&gt;</description>
      <pubDate>Thu, 29 Jun 2000 16:54:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428392#M2140</guid>
      <dc:creator>Albert E. Whale, CISSP</dc:creator>
      <dc:date>2000-06-29T16:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: while loop not working with remsh in a bourne shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428393#M2141</link>
      <description>Thanks!&lt;BR /&gt;&lt;BR /&gt;Adding the "-n" to the line worked.&lt;BR /&gt;&lt;BR /&gt;A co-worker also suggested the idea of kicking off via remsh a script on the remote systems that would kill the processes.  There are 29 that other systems.&lt;BR /&gt;&lt;BR /&gt;Adding the "-c" didn't work.  I received a "sh: -c: not found"&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Jun 2000 18:24:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428393#M2141</guid>
      <dc:creator>Boyd Kodama</dc:creator>
      <dc:date>2000-06-29T18:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: while loop not working with remsh in a bourne shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428394#M2142</link>
      <description>The -n is the correct solution.  The reason it failed is that remsh will by default pull input from stdin.  the while loop also relies on stdin.  Whenever you use a remsh within a while loop you need to use teh -n flag.</description>
      <pubDate>Thu, 29 Jun 2000 20:25:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428394#M2142</guid>
      <dc:creator>Alan Riggs</dc:creator>
      <dc:date>2000-06-29T20:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: while loop not working with remsh in a bourne shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428395#M2143</link>
      <description>_</description>
      <pubDate>Fri, 30 Jun 2000 00:42:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-loop-not-working-with-remsh-in-a-bourne-shell-script/m-p/2428395#M2143</guid>
      <dc:creator>Brian DeHamer</dc:creator>
      <dc:date>2000-06-30T00:42:57Z</dc:date>
    </item>
  </channel>
</rss>

