<?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 question on scripting in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763154#M101847</link>
    <description>i'm trying to issue a prompt in a script, that will require a y/n response before contining.  SO far, no luck.  ANy help would be appreciated. thanks&lt;BR /&gt;</description>
    <pubDate>Fri, 31 Mar 2006 09:41:47 GMT</pubDate>
    <dc:creator>Mark Harshman_1</dc:creator>
    <dc:date>2006-03-31T09:41:47Z</dc:date>
    <item>
      <title>question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763154#M101847</link>
      <description>i'm trying to issue a prompt in a script, that will require a y/n response before contining.  SO far, no luck.  ANy help would be appreciated. thanks&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Mar 2006 09:41:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763154#M101847</guid>
      <dc:creator>Mark Harshman_1</dc:creator>
      <dc:date>2006-03-31T09:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763155#M101848</link>
      <description>You need to use "read":&lt;BR /&gt;&lt;BR /&gt;echo "enter yes or no"&lt;BR /&gt;read ANSWER&lt;BR /&gt;&lt;BR /&gt;You can then test the variable for "yes" or "no".&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Fri, 31 Mar 2006 09:44:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763155#M101848</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2006-03-31T09:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763156#M101849</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt; This will do what you are looking for.&lt;BR /&gt;&lt;BR /&gt;  read answer&lt;BR /&gt;  if [ $answer = "Y" ]&lt;BR /&gt;  then&lt;BR /&gt;    do this&lt;BR /&gt;  else&lt;BR /&gt;    do this&lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;  You can also use case statment.&lt;BR /&gt;&lt;BR /&gt; Hope this helps.&lt;BR /&gt;&lt;BR /&gt;Shahul</description>
      <pubDate>Fri, 31 Mar 2006 09:46:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763156#M101849</guid>
      <dc:creator>Shahul</dc:creator>
      <dc:date>2006-03-31T09:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763157#M101850</link>
      <description>Hi Mark:&lt;BR /&gt;&lt;BR /&gt;#/usr/bin/sh&lt;BR /&gt;echo "Say something"&lt;BR /&gt;read REPLY&lt;BR /&gt;echo "You said ${REPLY} ...thank you!"&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 31 Mar 2006 09:47:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763157#M101850</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-03-31T09:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763158#M101851</link>
      <description>the echo statement prints the message, but doesnt pause for a reply, what am i missing? thanks&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Mar 2006 09:51:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763158#M101851</guid>
      <dc:creator>Mark Harshman_1</dc:creator>
      <dc:date>2006-03-31T09:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763159#M101852</link>
      <description>Hi Mark:&lt;BR /&gt;&lt;BR /&gt;The 'read' waits for input.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -l REPLY&lt;BR /&gt;echo "Answer 'y' or 'n' \c"&lt;BR /&gt;read REPLY&lt;BR /&gt;&lt;BR /&gt;while [ "${REPLY}" != "y" -a "${REPLY}" != "n" ]&lt;BR /&gt;do&lt;BR /&gt;   echo "Please answer 'y' or 'n'"&lt;BR /&gt;   read REPLY&lt;BR /&gt;done&lt;BR /&gt;echo "You replied '${REPLY}' -- thanks!"&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;...In the above script we keep asking for a REPLY until the user responds with a "y" or an "n".  The 'typeset -l' causes the contents of the REPLY variable which is filled by the 'read' to be translated to lowercase letters.  This makes the comparisons for a proper response easy.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 31 Mar 2006 10:13:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763159#M101852</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-03-31T10:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763160#M101853</link>
      <description>The read command should pause and wait form input; however, a few things could make it not do this:&lt;BR /&gt;&lt;BR /&gt;1) You have redirected stdin.&lt;BR /&gt;2) There are already characters in the input buffer so the reply is being satisfied from the buffer.&lt;BR /&gt;3) No read permission on the stdin device.&lt;BR /&gt;4) You have changed the terminal characterics so that it times out if no characters are available.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Mar 2006 10:21:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763160#M101853</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-03-31T10:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763161#M101854</link>
      <description>ok, i am trying to use this within a read-while-do setup.  I am trying basically reading a file, and asking the user if they want to proceed with the entry printed.  Doing the "echo" and "read" within this does not seem to work.  is there a way i can still do this within my existing read-while-do?  am i confusing the issue? thanks&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Mar 2006 10:25:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763161#M101854</guid>
      <dc:creator>Mark Harshman_1</dc:creator>
      <dc:date>2006-03-31T10:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763162#M101855</link>
      <description>Hi Mark:&lt;BR /&gt;&lt;BR /&gt;If you are issuing a 'read' to collect a user's input and are already reading a file, you will need to use *separate* file descriptors to keep the data segregated.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;exec 3&amp;lt;&amp;amp;0&lt;BR /&gt;cat /etc/hosts | 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&lt;BR /&gt;&lt;BR /&gt;If the above example, I'm reading LINEs from the '/etc/hosts file; echoing them to STDOUT; and *read*ing from STDIN into the REPLY variable.  The 'read -u' variation says that I want that read to be from file descriptor #3 which is a duplicate of descriptor zero (0) [STDIN]  the beginning of the script.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 31 Mar 2006 10:32:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763162#M101855</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-03-31T10:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763163#M101856</link>
      <description>It sounds like you redirect input with the while loop. You can force read to read from another device then STDIN.&lt;BR /&gt; &lt;BR /&gt;read REPLY &amp;lt;&amp;amp;2&lt;BR /&gt; &lt;BR /&gt;This will force read to read from STDERR which should still be assigned to your terminal.&lt;BR /&gt; &lt;BR /&gt;Or if STDERR is redirected, then you can use-&lt;BR /&gt; &lt;BR /&gt;read REPLY  &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 31 Mar 2006 10:35:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763163#M101856</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-03-31T10:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763164#M101857</link>
      <description>ok, the re-direct worked good, thanks.  Now i have one more issue.  If the answer is "n", i want to throw it back to my "cat-while-read" statement, if the answer is "y", i want to do a couple things before going back to the the "cat-while-read" statement.  I obviously have this wrong cause its falling all the way thru.  Thanks for your patience with a rookie scripter.&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Mar 2006 10:41:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763164#M101857</guid>
      <dc:creator>Mark Harshman_1</dc:creator>
      <dc:date>2006-03-31T10:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763165#M101858</link>
      <description>Hi Mark:&lt;BR /&gt;&lt;BR /&gt;For loops you can 'break' or 'continue'.  &lt;BR /&gt;&lt;BR /&gt;A 'break' terminates the loop.  A 'continue' will cause control to begin again at the top of the loop.&lt;BR /&gt;&lt;BR /&gt;The manpages for 'sh-posix' are quite useful:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/B2355-60127/sh-posix.1.html" target="_blank"&gt;http://docs.hp.com/en/B2355-60127/sh-posix.1.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 31 Mar 2006 10:46:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763165#M101858</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-03-31T10:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: question on scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763166#M101859</link>
      <description>With out seeing that section of code, it's hard to understand where you are coming from.&lt;BR /&gt; &lt;BR /&gt;If the "read" is in the while-loop, then just follow with a structured if-&lt;BR /&gt; &lt;BR /&gt;read REPLY if [[ "$REPLY" = "y" ]] ; then&lt;BR /&gt;echo "answer was y"&lt;BR /&gt;fi&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 31 Mar 2006 11:01:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/question-on-scripting/m-p/3763166#M101859</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-03-31T11:01:04Z</dc:date>
    </item>
  </channel>
</rss>

