<?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: test so $ANS must start with a numeric or alpha in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167124#M681635</link>
    <description>while read ANS&lt;BR /&gt;do&lt;BR /&gt;  ANS2="${ANS#[0-9a-zA-Z]}"&lt;BR /&gt;  if [ "${ANS}" == "${ANS2}" ]&lt;BR /&gt;  then&lt;BR /&gt;    echo not valid try again&lt;BR /&gt;    continue&lt;BR /&gt;  fi&lt;BR /&gt;  break&lt;BR /&gt;done</description>
    <pubDate>Tue, 31 Mar 2009 14:49:45 GMT</pubDate>
    <dc:creator>Laurent Menase</dc:creator>
    <dc:date>2009-03-31T14:49:45Z</dc:date>
    <item>
      <title>test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167123#M681634</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I want to write a test so that the user must enter a numeric or alpha character:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    echo "Please enter your name before you login: \c"&lt;BR /&gt;&lt;BR /&gt;while read ANS&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;        if [[ ${ANS} = "^[0-9][aA-Zz]" ]] ; then&lt;BR /&gt;&lt;BR /&gt;             do something&lt;BR /&gt;&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;this doesn't seem to work - I want a value to be entered to ANS&lt;BR /&gt;&lt;BR /&gt;how can I make this loop until ANS = something&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Tue, 31 Mar 2009 14:24:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167123#M681634</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2009-03-31T14:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167124#M681635</link>
      <description>while read ANS&lt;BR /&gt;do&lt;BR /&gt;  ANS2="${ANS#[0-9a-zA-Z]}"&lt;BR /&gt;  if [ "${ANS}" == "${ANS2}" ]&lt;BR /&gt;  then&lt;BR /&gt;    echo not valid try again&lt;BR /&gt;    continue&lt;BR /&gt;  fi&lt;BR /&gt;  break&lt;BR /&gt;done</description>
      <pubDate>Tue, 31 Mar 2009 14:49:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167124#M681635</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2009-03-31T14:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167125#M681636</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;variable cannot start with numeric..</description>
      <pubDate>Tue, 31 Mar 2009 15:01:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167125#M681636</guid>
      <dc:creator>Ganesan R</dc:creator>
      <dc:date>2009-03-31T15:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167126#M681637</link>
      <description>read ANS;&lt;BR /&gt;test="-1";&lt;BR /&gt;while [ "$test" = '-1' ]&lt;BR /&gt;do&lt;BR /&gt;test="1";&lt;BR /&gt;case $ANS in&lt;BR /&gt;        y | Y ) answer="y";;&lt;BR /&gt;        n | N ) answer="n";;&lt;BR /&gt;        *) finish="-1";&lt;BR /&gt;           echo -n 'Invalid response -- please reenter:';&lt;BR /&gt;           read answer;;&lt;BR /&gt;       esac&lt;BR /&gt;done&lt;BR /&gt;~&lt;BR /&gt;</description>
      <pubDate>Tue, 31 Mar 2009 15:08:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167126#M681637</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2009-03-31T15:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167127#M681638</link>
      <description>/*sorry should have been 'test' and not 'finish' with case statement */&lt;BR /&gt;&lt;BR /&gt;read ANS;&lt;BR /&gt;test="-1";&lt;BR /&gt;while [ "$test" = '-1' ]&lt;BR /&gt;do&lt;BR /&gt;test="1";&lt;BR /&gt;case $ANS in&lt;BR /&gt;y | Y ) answer="y";;&lt;BR /&gt;n | N ) answer="n";;&lt;BR /&gt;*) test="-1";&lt;BR /&gt;echo -n 'Invalid response -- please reenter:';&lt;BR /&gt;read answer;;&lt;BR /&gt;esac&lt;BR /&gt;done</description>
      <pubDate>Tue, 31 Mar 2009 15:10:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167127#M681638</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2009-03-31T15:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167128#M681639</link>
      <description>&lt;!--!*#--&gt;Hi Chris:&lt;BR /&gt;&lt;BR /&gt;I like to do this like:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -l ANS&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;    echo "Enter y|n \c"&lt;BR /&gt;    read   ANS&lt;BR /&gt;    case ${ANS} in&lt;BR /&gt;    "y"|"yes" )&lt;BR /&gt;        echo "OK"&lt;BR /&gt;        break&lt;BR /&gt;    ;;&lt;BR /&gt;    "n"|"no"  )&lt;BR /&gt;        echo "Thanks anyway..."&lt;BR /&gt;        break&lt;BR /&gt;    ;;&lt;BR /&gt;    * )&lt;BR /&gt;        echo "please say y|n"&lt;BR /&gt;    esac&lt;BR /&gt;done&lt;BR /&gt;echo "...and the answer was '${ANS}'"&lt;BR /&gt;&lt;BR /&gt;...the 'typeset -l' downcases every response making the tests very simple, especially if you demanded that your user reply "yes" or "No" instead of a one-character response.  As written, mix-case responses are easily digested too.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 31 Mar 2009 15:30:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167128#M681639</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-03-31T15:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167129#M681640</link>
      <description>hi (again) Chris:&lt;BR /&gt;&lt;BR /&gt;Sorry, I read your "...how can I make this loop until ANS = something..." and ignored the subject line request for handling numeric or alpha input.  Using the orgiginal suggestion of mine, amended:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -l ANS&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;    echo "Enter y|n \c"&lt;BR /&gt;    read   ANS&lt;BR /&gt;    case ${ANS} in&lt;BR /&gt;    "y"|"yes" )&lt;BR /&gt;        echo "OK"&lt;BR /&gt;        break&lt;BR /&gt;    ;;&lt;BR /&gt;    "n"|"no"  )&lt;BR /&gt;        echo "Thanks anyway..."&lt;BR /&gt;        break&lt;BR /&gt;    ;;&lt;BR /&gt;    [0-9]* )&lt;BR /&gt;        echo "digits ok too"&lt;BR /&gt;        break&lt;BR /&gt;    ;;&lt;BR /&gt;    * )&lt;BR /&gt;        echo "please say y|n|[0-9]*"&lt;BR /&gt;    esac&lt;BR /&gt;done&lt;BR /&gt;echo "...and the answer was '${ANS}'"&lt;BR /&gt;&lt;BR /&gt;/* no additional points necessary for this correction */&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 31 Mar 2009 15:41:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167129#M681640</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-03-31T15:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167130#M681641</link>
      <description>&amp;gt;if [[ ${ANS} = "^[0-9][aA-Zz]" ]] ; then&lt;BR /&gt;&lt;BR /&gt;The string compare test takes a pattern:&lt;BR /&gt;if [[ ${ANS} = [0-9a-zA-Z]* ]]; then&lt;BR /&gt;&lt;BR /&gt;The "*" says ignore the rest of the string.  You could use Laurent's trick for looking at each char.  (Note there is no == operator in [ ... ].&lt;BR /&gt;&lt;BR /&gt;Or you could just use grep to test:&lt;BR /&gt;echo ${ANS} | grep -q "^[0-9a-zA-Z]*$"&lt;BR /&gt;if [ $? -eq 0 ]; then</description>
      <pubDate>Tue, 31 Mar 2009 15:42:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167130#M681641</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-03-31T15:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167131#M681642</link>
      <description>This pattern may work:&lt;BR /&gt;if [[ ${ANS} = +([0-9a-zA-Z]) ]]; then&lt;BR /&gt;&lt;BR /&gt;&amp;gt;JRF: [0-9]* )&lt;BR /&gt;&lt;BR /&gt;case takes a pattern not a RE.  So that would be: +([0-9])</description>
      <pubDate>Tue, 31 Mar 2009 15:49:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167131#M681642</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-03-31T15:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167132#M681643</link>
      <description>indeed I followed the title constraint. not the text one,&lt;BR /&gt;and indeed == is a typo.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 31 Mar 2009 16:20:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167132#M681643</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2009-03-31T16:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167133#M681644</link>
      <description>Yes, this pattern does work for all alpha or numeric:&lt;BR /&gt;if [[ ${ANS} = +([0-9a-zA-Z]) ]]; then</description>
      <pubDate>Tue, 31 Mar 2009 19:15:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167133#M681644</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-03-31T19:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: test so $ANS must start with a numeric or alpha</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167134#M681645</link>
      <description>ok thanks everyone ...&lt;BR /&gt;&lt;BR /&gt;I'll play around and see what I come up with from your suggestions however all good examples!&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Wed, 01 Apr 2009 07:39:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-so-ans-must-start-with-a-numeric-or-alpha/m-p/5167134#M681645</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2009-04-01T07:39:39Z</dc:date>
    </item>
  </channel>
</rss>

