<?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 or for loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087224#M309902</link>
    <description>Thanks for the responses.&lt;BR /&gt;&lt;BR /&gt;Nah, export is not going to help ... I tried to  echo '${HOST} - ${USERS}' earlier and it worked fine - went through the list and echo'ed it just like I expected, its just when I put in the ssh/ttlg line that it exits after the first line ... may be with ssh there are options like BatchMode etc that might work, but I am really not sure if 'ttlg' has any ...&lt;BR /&gt;&lt;BR /&gt;Anyways, any other thoughts/suggestions are welcome.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shabu</description>
    <pubDate>Tue, 16 Oct 2007 23:27:12 GMT</pubDate>
    <dc:creator>Shabu Khan-2</dc:creator>
    <dc:date>2007-10-16T23:27:12Z</dc:date>
    <item>
      <title>while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087220#M309898</link>
      <description>&lt;BR /&gt;I am so embarrased to ask this question after writing thousands of shell scripts ... but I'll ask anyways :)&lt;BR /&gt;&lt;BR /&gt;My input file looks like this:&lt;BR /&gt;server1:user1 user2 user3&lt;BR /&gt;server2:user1 user2&lt;BR /&gt;server3:user1 user3&lt;BR /&gt;.......&lt;BR /&gt;&lt;BR /&gt;I am reading this way:&lt;BR /&gt;SAVE_IFS="${IFS}"&lt;BR /&gt;IFS=":"&lt;BR /&gt;&lt;BR /&gt;while read HOST USERS; do&lt;BR /&gt;  do something ....&lt;BR /&gt;done &lt;BR /&gt;IFS="${SAVE_IFS}"&lt;BR /&gt;&lt;BR /&gt;It just exits after the first read and wouldn't move on, I tried cat'ng the file out and piping it to while read but still the same issue ...&lt;BR /&gt;&lt;BR /&gt;I want the variable HOST to get the server name and the USERS to get the rest of the line ...&lt;BR /&gt;&lt;BR /&gt;Any thoughts?&lt;BR /&gt;&lt;BR /&gt;What is going on?</description>
      <pubDate>Tue, 16 Oct 2007 19:18:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087220#M309898</guid>
      <dc:creator>Shabu Khan-2</dc:creator>
      <dc:date>2007-10-16T19:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087221#M309899</link>
      <description>Not sure what's wrong as it runs w/o problems on my machine. Are you doing a remsh to a remote server by any chance? Run it in debug mode by inserting the line below at the very top of your script and post its output i.e.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh -x&lt;BR /&gt;&amp;lt;...rest of script...&amp;gt;</description>
      <pubDate>Tue, 16 Oct 2007 19:38:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087221#M309899</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-10-16T19:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087222#M309900</link>
      <description>&lt;BR /&gt;Yes, I am ssh'ng in (actually ttlg'ng in, this is opsware's version of ssh works the same way as ssh) ...&lt;BR /&gt;&lt;BR /&gt;I ran it in debug mode earlier, just exits after the first read, nothing useful ...</description>
      <pubDate>Tue, 16 Oct 2007 19:46:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087222#M309900</guid>
      <dc:creator>Shabu Khan-2</dc:creator>
      <dc:date>2007-10-16T19:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087223#M309901</link>
      <description>You need to export the value of IFS to the shell.  That is, your second line should be&lt;BR /&gt;&lt;BR /&gt;export IFS=":"&lt;BR /&gt;&lt;BR /&gt;Otherwise, nothing later "knows" about the value, since it was never exported into the shell's environment.  I *think*...</description>
      <pubDate>Tue, 16 Oct 2007 22:26:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087223#M309901</guid>
      <dc:creator>Michael Mike Reaser</dc:creator>
      <dc:date>2007-10-16T22:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087224#M309902</link>
      <description>Thanks for the responses.&lt;BR /&gt;&lt;BR /&gt;Nah, export is not going to help ... I tried to  echo '${HOST} - ${USERS}' earlier and it worked fine - went through the list and echo'ed it just like I expected, its just when I put in the ssh/ttlg line that it exits after the first line ... may be with ssh there are options like BatchMode etc that might work, but I am really not sure if 'ttlg' has any ...&lt;BR /&gt;&lt;BR /&gt;Anyways, any other thoughts/suggestions are welcome.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shabu</description>
      <pubDate>Tue, 16 Oct 2007 23:27:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087224#M309902</guid>
      <dc:creator>Shabu Khan-2</dc:creator>
      <dc:date>2007-10-16T23:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087225#M309903</link>
      <description>&amp;gt;Mike: You need to export the value of IFS to the shell.&lt;BR /&gt;&lt;BR /&gt;No, exporting IFS is near useless.  As soon as you create a new shell, it is reset.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Mike: Otherwise, nothing later "knows" about the value,&lt;BR /&gt;&lt;BR /&gt;Nothing later needs to know.  Only the current shell and that doesn't need to have it exported.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;it's just when I put in the ssh/ttlg line that it exits after the first line &lt;BR /&gt;&lt;BR /&gt;Can you show what you mean?&lt;BR /&gt;When I use: ssh machine script-with-read&lt;BR /&gt;this works fine.&lt;BR /&gt;&lt;BR /&gt;Are you using "ssh $HOST $USER" within your while loop?  If so, you need to use:&lt;BR /&gt;ssh -n $HOST $USER&lt;BR /&gt;&lt;BR /&gt;Otherwise ssh eats your input from /tmp/myinput.</description>
      <pubDate>Wed, 17 Oct 2007 02:11:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087225#M309903</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-10-17T02:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087226#M309904</link>
      <description>Over the years I have fallen out of love of tweaking IFS for such a simple case.  I would handle this case through parameter expansions:&lt;BR /&gt;&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;  HOST=${LINE%%:*}&lt;BR /&gt;  USERS=${LINE#*:}&lt;BR /&gt;&lt;BR /&gt;...  do something&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Yes, you can make IFS work.  It is just that so often what you think you told the shell is not what you said.</description>
      <pubDate>Wed, 17 Oct 2007 10:11:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087226#M309904</guid>
      <dc:creator>Bob E Campbell</dc:creator>
      <dc:date>2007-10-17T10:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087227#M309905</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;have you specified which shell interpreter to use in the first line?&lt;BR /&gt;If not, try&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Wed, 17 Oct 2007 10:44:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087227#M309905</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2007-10-17T10:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087228#M309906</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;calling a ssh in your loop will eat al remaining input, because ssh read stdin as well.&lt;BR /&gt;A usage of 'ssh -n' will prevent that command doing so.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Wed, 17 Oct 2007 12:56:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087228#M309906</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-10-17T12:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087229#M309907</link>
      <description>Hi Shabu,&lt;BR /&gt;my suggetion is to load the HOSt USER into an array and after perform another loop reading data for array. probbaly the sheel used withi the first loop read the rest of teh file as STDIN.&lt;BR /&gt;Just my .02$&lt;BR /&gt;Art</description>
      <pubDate>Thu, 18 Oct 2007 03:44:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087229#M309907</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2007-10-18T03:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087230#M309908</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;if you change&lt;BR /&gt;do something&lt;BR /&gt;in your script to&lt;BR /&gt;echo "hello $HOST $USERS"&lt;BR /&gt;&lt;BR /&gt;does the script then produce only a single line of output? If yes, it must be the "do something" that causes the exit.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Thu, 18 Oct 2007 04:23:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087230#M309908</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2007-10-18T04:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: while or for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087231#M309909</link>
      <description>Using tusc you can see the read in ssh that eats up the data.  That's after the shell goes out of its way to put the file pointer back to the next unread line.</description>
      <pubDate>Fri, 19 Oct 2007 14:57:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-or-for-loop/m-p/4087231#M309909</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-10-19T14:57:19Z</dc:date>
    </item>
  </channel>
</rss>

