<?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: shell script - read doesn't work in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681339#M908522</link>
    <description>It looks like the line "read ans" is reading from your input file, i.e. from $1.  Try redirecting stdin into the read, i.e:&lt;BR /&gt;&lt;BR /&gt;the line:&lt;BR /&gt;&lt;BR /&gt;  read ans&lt;BR /&gt;&lt;BR /&gt;become:&lt;BR /&gt;&lt;BR /&gt;  read ans &amp;lt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;-Santosh&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 12 Mar 2002 16:19:38 GMT</pubDate>
    <dc:creator>Santosh Nair_1</dc:creator>
    <dc:date>2002-03-12T16:19:38Z</dc:date>
    <item>
      <title>shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681333#M908516</link>
      <description>Hi guys,&lt;BR /&gt;&lt;BR /&gt;For some reason, this script doesn't stop at read to read user answer (Y/N) and for somehow N is always assumed!&lt;BR /&gt;&lt;BR /&gt;sed "s/,/ /g" $1|while read line&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;LVSTRING="${LVCREATE} -i ${LVSTRIP}"&lt;BR /&gt;&lt;BR /&gt;echo "\n Striping will be used"&lt;BR /&gt;echo " Number of spindles to be used is "&lt;BR /&gt;echo "\nWould you like to change the number of spindles (y/n)[n]: \c"&lt;BR /&gt;read ans&lt;BR /&gt;ans=$(echo $ans |tr "[a-z]" "[A-Z]")&lt;BR /&gt;if [ "$ans" = "Y" ]; then&lt;BR /&gt; echo "YES"&lt;BR /&gt;else&lt;BR /&gt; echo "NO"&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Thank you.</description>
      <pubDate>Tue, 12 Mar 2002 16:11:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681333#M908516</guid>
      <dc:creator>andi_1</dc:creator>
      <dc:date>2002-03-12T16:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681334#M908517</link>
      <description>insert the line&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;at the top of the script..&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill</description>
      <pubDate>Tue, 12 Mar 2002 16:12:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681334#M908517</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-03-12T16:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681335#M908518</link>
      <description>kibo:root&amp;gt; /tmp/scr&lt;BR /&gt;&lt;BR /&gt; Striping will be used&lt;BR /&gt; Number of spindles to be used is&lt;BR /&gt;&lt;BR /&gt;Would you like to change the number of spindles (y/n)[n]: n&lt;BR /&gt;NO&lt;BR /&gt;&lt;BR /&gt;Works for me:&lt;BR /&gt;&lt;BR /&gt;kibo:root&amp;gt; cat /tmp/scr&lt;BR /&gt;echo "\n Striping will be used"&lt;BR /&gt;echo " Number of spindles to be used is "&lt;BR /&gt;echo "\nWould you like to change the number of spindles (y/n)[n]: \c"&lt;BR /&gt;read ans&lt;BR /&gt;ans=$(echo $ans |tr "[a-z]" "[A-Z]")&lt;BR /&gt;if [ "$ans" = "Y" ]; then&lt;BR /&gt;echo "YES"&lt;BR /&gt;else&lt;BR /&gt;echo "NO"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill</description>
      <pubDate>Tue, 12 Mar 2002 16:14:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681335#M908518</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-03-12T16:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681336#M908519</link>
      <description>I do have #!/bin/ksh</description>
      <pubDate>Tue, 12 Mar 2002 16:15:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681336#M908519</guid>
      <dc:creator>andi_1</dc:creator>
      <dc:date>2002-03-12T16:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681337#M908520</link>
      <description>Bill,&lt;BR /&gt;&lt;BR /&gt;If I remove while loop it works, but I need to have while loops since its in the while loop I read file and determine striping&lt;BR /&gt;&lt;BR /&gt;I hope read can work in the while loop</description>
      <pubDate>Tue, 12 Mar 2002 16:17:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681337#M908520</guid>
      <dc:creator>andi_1</dc:creator>
      <dc:date>2002-03-12T16:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681338#M908521</link>
      <description>Watch out for your nested if&lt;BR /&gt;and multiple use of the same variable.&lt;BR /&gt;&lt;BR /&gt;other than that, term emulation or env should be looked at.&lt;BR /&gt;&lt;BR /&gt;Dis you try to add a set -x in the script.&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Mar 2002 16:18:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681338#M908521</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-03-12T16:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681339#M908522</link>
      <description>It looks like the line "read ans" is reading from your input file, i.e. from $1.  Try redirecting stdin into the read, i.e:&lt;BR /&gt;&lt;BR /&gt;the line:&lt;BR /&gt;&lt;BR /&gt;  read ans&lt;BR /&gt;&lt;BR /&gt;become:&lt;BR /&gt;&lt;BR /&gt;  read ans &amp;lt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;-Santosh&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Mar 2002 16:19:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681339#M908522</guid>
      <dc:creator>Santosh Nair_1</dc:creator>
      <dc:date>2002-03-12T16:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681340#M908523</link>
      <description>It looks like your sed is piping its output to the while loop, so the "read ans" is picking up its data from whatever you pass as a file to sed.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 12 Mar 2002 16:20:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681340#M908523</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-03-12T16:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681341#M908524</link>
      <description>If you use&lt;BR /&gt;&lt;BR /&gt;read -u3 ans&lt;BR /&gt;&lt;BR /&gt;Then it will do it's input from STDERR and do a real input from the terminal, assuming you haven't redirected STDERR.&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 12 Mar 2002 16:22:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681341#M908524</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-03-12T16:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681342#M908525</link>
      <description>&lt;BR /&gt;Would you like to change the number of spindles (y/n)[n]: n&lt;BR /&gt;NO&lt;BR /&gt;hello1111&lt;BR /&gt;&lt;BR /&gt; Striping will be used&lt;BR /&gt; Number of spindles to be used is&lt;BR /&gt;&lt;BR /&gt;Would you like to change the number of spindles (y/n)[n]: y&lt;BR /&gt;YES&lt;BR /&gt;hello111&lt;BR /&gt;&lt;BR /&gt; Striping will be used&lt;BR /&gt; Number of spindles to be used is&lt;BR /&gt;&lt;BR /&gt;Would you like to change the number of spindles (y/n)[n]: y&lt;BR /&gt;YES&lt;BR /&gt;hello11&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;where the script is:&lt;BR /&gt;for i in $(cat /tmp/file1)&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;echo "\n Striping will be used"&lt;BR /&gt;echo " Number of spindles to be used is "&lt;BR /&gt;echo "\nWould you like to change the number of spindles (y/n)[n]: \c"&lt;BR /&gt;read ans&lt;BR /&gt;ans=$(echo $ans |tr "[a-z]" "[A-Z]")&lt;BR /&gt;if [ "$ans" = "Y" ]; then&lt;BR /&gt;echo "YES"&lt;BR /&gt;else&lt;BR /&gt;echo "NO"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;echo $i&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and the file1 is:&lt;BR /&gt;&lt;BR /&gt;hello111111&lt;BR /&gt;hello11111&lt;BR /&gt;hello1111&lt;BR /&gt;hello111&lt;BR /&gt;hello11&lt;BR /&gt;~&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Mar 2002 16:22:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681342#M908525</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-03-12T16:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681343#M908526</link>
      <description>oops, i meant&lt;BR /&gt;&lt;BR /&gt;read -u2 ans&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 12 Mar 2002 16:24:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681343#M908526</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-03-12T16:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: shell script - read doesn't work</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681344#M908527</link>
      <description>Try sticking the portion of code inside the loop in a function of its own, then calling the function from inside the loop. Be sure to export any variables that are passed between.&lt;BR /&gt;&lt;BR /&gt;function prompt_user&lt;BR /&gt;{&lt;BR /&gt;    print "Are you really really sure?"&lt;BR /&gt;    read ans&lt;BR /&gt;&lt;BR /&gt;    export ans2=$ans&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sed .... |while read line&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;   prompt_user&lt;BR /&gt;&lt;BR /&gt;   /* Actions here */&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Share and Enjoy! Ian</description>
      <pubDate>Tue, 12 Mar 2002 16:24:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-read-doesn-t-work/m-p/2681344#M908527</guid>
      <dc:creator>Ian Dennison_1</dc:creator>
      <dc:date>2002-03-12T16:24:42Z</dc:date>
    </item>
  </channel>
</rss>

