<?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: User Input within a while loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666352#M49653</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;It will be clearer if you show us the code you have written.&lt;BR /&gt;&lt;BR /&gt;The stub should go something like this:&lt;BR /&gt;&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;# while loop runs until end of file&lt;BR /&gt;cat file | while read var1 var2 var3&lt;BR /&gt;do&lt;BR /&gt;  # process var1 var2 var3&lt;BR /&gt;  echo $var1 $var2 $var3&lt;BR /&gt;  echo "Press any key to continue\c"&lt;BR /&gt;  read&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
    <pubDate>Mon, 18 Feb 2002 05:00:09 GMT</pubDate>
    <dc:creator>Steven Sim Kok Leong</dc:creator>
    <dc:date>2002-02-18T05:00:09Z</dc:date>
    <item>
      <title>User Input within a while loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666351#M49652</link>
      <description>Hi,&lt;BR /&gt;I have a while loop which reads three variables from a file.. and after some processing further down the program I am expecting the user to hit enter to continue...&lt;BR /&gt;"Press enter to continue ... " read&lt;BR /&gt;but, when I execute the program it doesn't stop where it is supposed to but just runs till the program finishes.. when I executed with debugging on... I found that the second read basically reads the three variables that I specified in the while loop.. ? How do I fix this ?</description>
      <pubDate>Mon, 18 Feb 2002 04:51:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666351#M49652</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-02-18T04:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: User Input within a while loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666352#M49653</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;It will be clearer if you show us the code you have written.&lt;BR /&gt;&lt;BR /&gt;The stub should go something like this:&lt;BR /&gt;&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;# while loop runs until end of file&lt;BR /&gt;cat file | while read var1 var2 var3&lt;BR /&gt;do&lt;BR /&gt;  # process var1 var2 var3&lt;BR /&gt;  echo $var1 $var2 $var3&lt;BR /&gt;  echo "Press any key to continue\c"&lt;BR /&gt;  read&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Mon, 18 Feb 2002 05:00:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666352#M49653</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-02-18T05:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: User Input within a while loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666353#M49654</link>
      <description>Sure, here you go..&lt;BR /&gt;&lt;BR /&gt;Please find attachment..&lt;BR /&gt;&lt;BR /&gt;Thanks,</description>
      <pubDate>Mon, 18 Feb 2002 05:16:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666353#M49654</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-02-18T05:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: User Input within a while loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666354#M49655</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The command read reads from STDIN which is the input through the pipe&lt;BR /&gt;&lt;BR /&gt;cat file | while ...&lt;BR /&gt;&lt;BR /&gt;You can workaround this in your script as follows:&lt;BR /&gt;&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt; &lt;BR /&gt;total=`cat inputfile|wc -l|awk '{print $1}'`&lt;BR /&gt;cnt=1&lt;BR /&gt;while [ "$cnt" -le "$total" ]&lt;BR /&gt;do&lt;BR /&gt;  cat inputfile|tail +$cnt|head -1|read var1 var2 var3&lt;BR /&gt;  print $var1 $var2 $var3 &lt;BR /&gt;  print "Press any key to continue...\c"&lt;BR /&gt;  read &lt;BR /&gt;  cnt=`expr $cnt + 1`&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Mon, 18 Feb 2002 05:41:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666354#M49655</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-02-18T05:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: User Input within a while loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666355#M49656</link>
      <description>Thanks for your assistance Steve !&lt;BR /&gt;Makes sense.. pretty neat workaround... I should have thought about this earlier :-)&lt;BR /&gt;&lt;BR /&gt;-Shabu</description>
      <pubDate>Mon, 18 Feb 2002 05:57:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/user-input-within-a-while-loop/m-p/2666355#M49656</guid>
      <dc:creator>SHABU KHAN</dc:creator>
      <dc:date>2002-02-18T05:57:48Z</dc:date>
    </item>
  </channel>
</rss>

