<?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: Posix Scripting question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465402#M849022</link>
    <description>I got it to work by loading the file into seperate array variables then doing a seperate loop to process the array variables&lt;BR /&gt;&lt;BR /&gt;xx=1&lt;BR /&gt;cat filename|while read -r var1 var2&lt;BR /&gt;do&lt;BR /&gt;arr1[xx]=var1&lt;BR /&gt;arr2[xx]=var2&lt;BR /&gt;let "xx = xx +1"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;xx=1&lt;BR /&gt;cont=yes&lt;BR /&gt;while [ cont = yes ]&lt;BR /&gt;do&lt;BR /&gt;  if ! [ ${var1[xx]} ]&lt;BR /&gt;  then&lt;BR /&gt;    cont=no&lt;BR /&gt;    break&lt;BR /&gt;  fi&lt;BR /&gt;  askquestion&lt;BR /&gt;  read&lt;BR /&gt;  case&lt;BR /&gt;    .....&lt;BR /&gt;  esac&lt;BR /&gt;done&lt;BR /&gt;</description>
    <pubDate>Tue, 18 Jan 2005 12:17:47 GMT</pubDate>
    <dc:creator>Smucker</dc:creator>
    <dc:date>2005-01-18T12:17:47Z</dc:date>
    <item>
      <title>Posix Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465399#M849019</link>
      <description>I would like to read a file sequentially ans ask the user for input on selected records. the flow will be something like this&lt;BR /&gt;&lt;BR /&gt;while loop&lt;BR /&gt;read file&lt;BR /&gt;ask question&lt;BR /&gt;process if yes&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I tried the following but it failed to work&lt;BR /&gt;&lt;BR /&gt;while read &lt;BR /&gt;ask question&lt;BR /&gt;process if yes&lt;BR /&gt;done &lt;FILENAME&gt;&lt;/FILENAME&gt;&lt;BR /&gt;the ask question(read) was answered by the shell.  Any suggestions.</description>
      <pubDate>Tue, 18 Jan 2005 09:18:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465399#M849019</guid>
      <dc:creator>Smucker</dc:creator>
      <dc:date>2005-01-18T09:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Posix Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465400#M849020</link>
      <description>cat file | while read line&lt;BR /&gt;do&lt;BR /&gt;echo "Ask something to user"&lt;BR /&gt;read answer&lt;BR /&gt;if [[ ${answer} = "user_response" ]]&lt;BR /&gt;then&lt;BR /&gt;"whatever you want"&lt;BR /&gt;else&lt;BR /&gt;echo "something bad"&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Tue, 18 Jan 2005 09:29:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465400#M849020</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-01-18T09:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Posix Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465401#M849021</link>
      <description>sorry did not work.  Same results  the input redirection is answering the read command.&lt;BR /&gt;&lt;BR /&gt;any other suggestions? (below is the code snippet&lt;BR /&gt;*******************************&lt;BR /&gt;cat deletelist.txt|while read -r userid passwd comment&lt;BR /&gt;do&lt;BR /&gt;echo "Do you wish to process $userid on $1 - password is $passwd and comments are&lt;BR /&gt; $comment? \c"&lt;BR /&gt; read response&lt;BR /&gt; case $response in&lt;BR /&gt;   [y,Y,yes,YES])&lt;BR /&gt;      echo " $userid was processed "&lt;BR /&gt;      ;;&lt;BR /&gt;   [n,N,no,NO])&lt;BR /&gt;      echo " $userid was not processed "&lt;BR /&gt;     ;;&lt;BR /&gt;   *)&lt;BR /&gt;      echo " Assuming no was the intended response "&lt;BR /&gt;      echo "  You typed $response "&lt;BR /&gt;      echo " $userid was not processed"&lt;BR /&gt;      ;;&lt;BR /&gt;  esac&lt;BR /&gt;done&lt;BR /&gt;**********************</description>
      <pubDate>Tue, 18 Jan 2005 11:17:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465401#M849021</guid>
      <dc:creator>Smucker</dc:creator>
      <dc:date>2005-01-18T11:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Posix Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465402#M849022</link>
      <description>I got it to work by loading the file into seperate array variables then doing a seperate loop to process the array variables&lt;BR /&gt;&lt;BR /&gt;xx=1&lt;BR /&gt;cat filename|while read -r var1 var2&lt;BR /&gt;do&lt;BR /&gt;arr1[xx]=var1&lt;BR /&gt;arr2[xx]=var2&lt;BR /&gt;let "xx = xx +1"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;xx=1&lt;BR /&gt;cont=yes&lt;BR /&gt;while [ cont = yes ]&lt;BR /&gt;do&lt;BR /&gt;  if ! [ ${var1[xx]} ]&lt;BR /&gt;  then&lt;BR /&gt;    cont=no&lt;BR /&gt;    break&lt;BR /&gt;  fi&lt;BR /&gt;  askquestion&lt;BR /&gt;  read&lt;BR /&gt;  case&lt;BR /&gt;    .....&lt;BR /&gt;  esac&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jan 2005 12:17:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465402#M849022</guid>
      <dc:creator>Smucker</dc:creator>
      <dc:date>2005-01-18T12:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Posix Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465403#M849023</link>
      <description>another way to do this is with the while true loop:&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;echo "Ask the question, or x to exit. \c"&lt;BR /&gt;read answer&lt;BR /&gt;case $answer in &lt;BR /&gt;0)  do something;;&lt;BR /&gt;1)  do something;;&lt;BR /&gt;2)  do something&lt;BR /&gt;x) exit0&lt;BR /&gt;esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jan 2005 13:16:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465403#M849023</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2005-01-18T13:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Posix Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465404#M849024</link>
      <description>Since you have STDIN defined to the filename, then all "read" statements will be from that file.&lt;BR /&gt; &lt;BR /&gt;To have read, read from the terminal, try-&lt;BR /&gt;read answer &amp;lt;&amp;amp;2&lt;BR /&gt; &lt;BR /&gt;Assuming STDERR is still assigned to your terminal.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 18 Jan 2005 13:46:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465404#M849024</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2005-01-18T13:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: Posix Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465405#M849025</link>
      <description>You can have multiple inputs by using the "exec" command to assign a "file descriptor" number 3 to 9 (0=stdin, 1=stdout, 2=stderr) to a file and then use that number in a read command "-u" (or any other i/o command) - you can explicitly open and close these file descriptors and re-use them if you need to - please see "man sh-posix".&lt;BR /&gt;&lt;BR /&gt;example:&lt;BR /&gt;   exec 3&amp;lt; $SOME_INPUT_FILE&lt;BR /&gt;   while read -u3 a1 a2 a3 garbage&lt;BR /&gt;   do&lt;BR /&gt;     print "$a3"&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt;Good luck.&lt;BR /&gt;Bob</description>
      <pubDate>Wed, 19 Jan 2005 11:32:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465405#M849025</guid>
      <dc:creator>Robert Dill</dc:creator>
      <dc:date>2005-01-19T11:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Posix Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465406#M849026</link>
      <description>Perfect.  Worked like a dream thanks</description>
      <pubDate>Wed, 19 Jan 2005 14:28:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/posix-scripting-question/m-p/3465406#M849026</guid>
      <dc:creator>Smucker</dc:creator>
      <dc:date>2005-01-19T14:28:32Z</dc:date>
    </item>
  </channel>
</rss>

