<?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 script problem with read command... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967913#M720358</link>
    <description>I have a script that does a while read .... of a file and within there it does a function call to reply to a question being asked. The problem I am having is it gets to the second read statement and goes into a loop there. Is there a way around this or a better way to handle it ???&lt;BR /&gt;&lt;BR /&gt;Basically I want to read through a file and ask if they want to process this record or not ....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    while read turntype project filename revision&lt;BR /&gt;    do&lt;BR /&gt;      print "Processing line: "&lt;BR /&gt;      print "Processing line: " &amp;gt;&amp;gt; ${PVCS_LOG5}&lt;BR /&gt;      print "${turntype} ${project} ${filename} ${revision} "&lt;BR /&gt;      print "${turntype} ${project} ${filename} ${revision} " &amp;gt;&amp;gt; ${PVCS_LOG5}&lt;BR /&gt;      ask "Process this Regression Record? (Y/N) "&lt;BR /&gt;      if [ $? -eq 0 ]&lt;BR /&gt;        then&lt;BR /&gt;          if [ ${TYPE} = "tupinstallprod" ]&lt;BR /&gt;            then&lt;BR /&gt;......etc....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;function ask&lt;BR /&gt;{&lt;BR /&gt;    typeset rc&lt;BR /&gt;    rc=2&lt;BR /&gt;    while [ ${rc} -gt 1 ]&lt;BR /&gt;    do&lt;BR /&gt;        print -n ${1}&lt;BR /&gt;        sleep 2&lt;BR /&gt;        read answer&lt;BR /&gt;        if [ "${answer}" = "Y" -o "${answer}" = "y" ]; then&lt;BR /&gt;            rc=0&lt;BR /&gt;        elif [ "${answer}" = "N" -o "${answer}" = "n" ]; then&lt;BR /&gt;            rc=1&lt;BR /&gt;        else&lt;BR /&gt;            rc=2&lt;BR /&gt;        fi&lt;BR /&gt;    done&lt;BR /&gt;    return ${rc}&lt;BR /&gt;}</description>
    <pubDate>Wed, 07 May 2003 19:38:35 GMT</pubDate>
    <dc:creator>MikeL_4</dc:creator>
    <dc:date>2003-05-07T19:38:35Z</dc:date>
    <item>
      <title>script problem with read command...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967913#M720358</link>
      <description>I have a script that does a while read .... of a file and within there it does a function call to reply to a question being asked. The problem I am having is it gets to the second read statement and goes into a loop there. Is there a way around this or a better way to handle it ???&lt;BR /&gt;&lt;BR /&gt;Basically I want to read through a file and ask if they want to process this record or not ....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    while read turntype project filename revision&lt;BR /&gt;    do&lt;BR /&gt;      print "Processing line: "&lt;BR /&gt;      print "Processing line: " &amp;gt;&amp;gt; ${PVCS_LOG5}&lt;BR /&gt;      print "${turntype} ${project} ${filename} ${revision} "&lt;BR /&gt;      print "${turntype} ${project} ${filename} ${revision} " &amp;gt;&amp;gt; ${PVCS_LOG5}&lt;BR /&gt;      ask "Process this Regression Record? (Y/N) "&lt;BR /&gt;      if [ $? -eq 0 ]&lt;BR /&gt;        then&lt;BR /&gt;          if [ ${TYPE} = "tupinstallprod" ]&lt;BR /&gt;            then&lt;BR /&gt;......etc....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;function ask&lt;BR /&gt;{&lt;BR /&gt;    typeset rc&lt;BR /&gt;    rc=2&lt;BR /&gt;    while [ ${rc} -gt 1 ]&lt;BR /&gt;    do&lt;BR /&gt;        print -n ${1}&lt;BR /&gt;        sleep 2&lt;BR /&gt;        read answer&lt;BR /&gt;        if [ "${answer}" = "Y" -o "${answer}" = "y" ]; then&lt;BR /&gt;            rc=0&lt;BR /&gt;        elif [ "${answer}" = "N" -o "${answer}" = "n" ]; then&lt;BR /&gt;            rc=1&lt;BR /&gt;        else&lt;BR /&gt;            rc=2&lt;BR /&gt;        fi&lt;BR /&gt;    done&lt;BR /&gt;    return ${rc}&lt;BR /&gt;}</description>
      <pubDate>Wed, 07 May 2003 19:38:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967913#M720358</guid>
      <dc:creator>MikeL_4</dc:creator>
      <dc:date>2003-05-07T19:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: script problem with read command...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967914#M720359</link>
      <description>Since I assume your STDIN is set to an input file, you need to have the second read do the input from the terminal. Try-&lt;BR /&gt;&lt;BR /&gt;read answer &amp;lt;&amp;amp;2&lt;BR /&gt;&lt;BR /&gt;This will force read to read from your STDERR (assuming to be the terminal).&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Wed, 07 May 2003 19:53:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967914#M720359</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-05-07T19:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: script problem with read command...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967915#M720360</link>
      <description>Hi Michael:&lt;BR /&gt;&lt;BR /&gt;In order to keep the reads "straight" you need to establish another file descriptor.  By example: &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh &lt;BR /&gt;exec 3&amp;lt;&amp;amp;0 &lt;BR /&gt;while read LINE &lt;BR /&gt;do &lt;BR /&gt;echo "${LINE} &lt;BR /&gt;read -u3 REPLY &lt;BR /&gt;echo "You said: ${REPLY}" &lt;BR /&gt;done &amp;lt; filename &lt;BR /&gt;&lt;BR /&gt;Regards! &lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 07 May 2003 19:54:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967915#M720360</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-05-07T19:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: script problem with read command...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967916#M720361</link>
      <description>Hi (again) Michael:&lt;BR /&gt;&lt;BR /&gt;As an aside, here's one other trick you will find useful.  Instead of testing your 'answer' variable for uppercase and lowercase letters, use 'typeset -l' to translate to lowercase when variable assignment is made:&lt;BR /&gt;&lt;BR /&gt;typeset -l answer&lt;BR /&gt;read -u3 answer &lt;BR /&gt;if [ "${ansser}" = y ]; then&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 07 May 2003 20:11:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967916#M720361</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-05-07T20:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: script problem with read command...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967917#M720362</link>
      <description>Another "trick" is to read from /dev/tty. This pseudo device is always your terminal.&lt;BR /&gt;&lt;BR /&gt;e.g. read answer &amp;lt; /dev/tty</description>
      <pubDate>Wed, 07 May 2003 20:18:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967917#M720362</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-05-07T20:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: script problem with read command...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967918#M720363</link>
      <description>I had a similar question sometime ago.  The answers I got were similar, but thought it might be helpful for you to review the responses to my question as well.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xfdac3a7b3682d611abdb0090277a778c,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xfdac3a7b3682d611abdb0090277a778c,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Kurt Renner</description>
      <pubDate>Thu, 08 May 2003 12:10:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-problem-with-read-command/m-p/2967918#M720363</guid>
      <dc:creator>Kurt Renner</dc:creator>
      <dc:date>2003-05-08T12:10:21Z</dc:date>
    </item>
  </channel>
</rss>

