<?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: How to validate input as an integer in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925170#M408716</link>
    <description>Hi RAC,&lt;BR /&gt;&lt;BR /&gt;I got the logic of the case syntax. Thanks a lot. It helps me to solve the problem&lt;BR /&gt;&lt;BR /&gt;Thanks for the support guys.&lt;BR /&gt;regards,&lt;BR /&gt;AJi</description>
    <pubDate>Mon, 12 Sep 2005 04:56:23 GMT</pubDate>
    <dc:creator>Aji Thomas</dc:creator>
    <dc:date>2005-09-12T04:56:23Z</dc:date>
    <item>
      <title>How to validate input as an integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925163#M408709</link>
      <description>hi guys,&lt;BR /&gt;&lt;BR /&gt;I have a script that requires to input hour and minute, But i am unable to validate the input as integer. Is there any unix command that i can include in the shell script to validate it.&lt;BR /&gt;&lt;BR /&gt;Including the shell script&lt;BR /&gt;-------------------------------------------&lt;BR /&gt;&lt;BR /&gt;printf "\nSchehule Time"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while [ "$Hour" -lt "1" -o "$Hour" -gt "12" ]&lt;BR /&gt;do&lt;BR /&gt;        printf "\nHour: (1-12) [08] "&lt;BR /&gt;        read Hour&lt;BR /&gt;        if [ "$Hour" = "" ]; then&lt;BR /&gt;        Hour=08;&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;echo "$?"&lt;BR /&gt;&lt;BR /&gt;while [ "$Minute" -lt "1" -o "$Minute" -gt "59" ]&lt;BR /&gt;do&lt;BR /&gt;        printf "Minute: (01-59) [30] "&lt;BR /&gt;        read Minute&lt;BR /&gt;        if [ "$Minute" = "" ]; then&lt;BR /&gt;        Minute=30;&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;printf "\nTime scheduled is $Hour:$Minute\n"&lt;BR /&gt;&lt;BR /&gt;-------------------------------------------&lt;BR /&gt;Please advice me,&lt;BR /&gt;AJi</description>
      <pubDate>Mon, 12 Sep 2005 04:19:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925163#M408709</guid>
      <dc:creator>Aji Thomas</dc:creator>
      <dc:date>2005-09-12T04:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate input as an integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925164#M408710</link>
      <description>Hi Aji ,&lt;BR /&gt;&lt;BR /&gt;You can use  expr to treet that as an integer:&lt;BR /&gt;&lt;BR /&gt;Ex:&lt;BR /&gt;&lt;BR /&gt;i=1&lt;BR /&gt;echo $i &lt;BR /&gt;while [ $i -le 10 ]&lt;BR /&gt;do&lt;BR /&gt;echo " $i is less than 10 ]&lt;BR /&gt;i=`expr $i + 1`&lt;BR /&gt;done&lt;BR /&gt;--------------&lt;BR /&gt;&lt;BR /&gt;Hope this will help ,&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Raj.</description>
      <pubDate>Mon, 12 Sep 2005 04:39:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925164#M408710</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2005-09-12T04:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate input as an integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925165#M408711</link>
      <description>You can use typeset to force variables to be integers.  So: -&lt;BR /&gt;&lt;BR /&gt;typeset -i hour&lt;BR /&gt;read hour&lt;BR /&gt;&lt;BR /&gt;This will then guarantee that $hour is an integer.  If the user enters text instead of a number, the value will be 0&lt;BR /&gt;&lt;BR /&gt;You can then validate the range is between 1 and 12 as required, happy that $hour will be a proper integer.</description>
      <pubDate>Mon, 12 Sep 2005 04:42:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925165#M408711</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2005-09-12T04:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate input as an integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925166#M408712</link>
      <description>come case statements.&lt;BR /&gt;&lt;BR /&gt;echo "key in hour"&lt;BR /&gt;&lt;BR /&gt;read hour&lt;BR /&gt;&lt;BR /&gt;case $hour in&lt;BR /&gt;[0-9]|1[0-9]|2[0-9])&lt;BR /&gt;echo "your choice - $hour"&lt;BR /&gt;echo "going ahead";;&lt;BR /&gt;*)&lt;BR /&gt;echo "bad choice for hour-$hour"&lt;BR /&gt;;;&lt;BR /&gt;esac&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Sep 2005 04:45:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925166#M408712</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-09-12T04:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate input as an integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925167#M408713</link>
      <description>Hi Aji ,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here you have ti change , &lt;BR /&gt;&lt;BR /&gt;read Minute&lt;BR /&gt;if [ "$Minute" = "" ]; then&lt;BR /&gt;&lt;BR /&gt;You need to remove the quote to treet as a integer , and you can do the comparisiion statement like , -le (Less than ) -ge (Greater than ) or -eq (Equal ) , or = , &lt;BR /&gt;&lt;BR /&gt;so try making :&lt;BR /&gt;&lt;BR /&gt;read Minute&lt;BR /&gt;if [ $Minute = integer_value ]&lt;BR /&gt;then &lt;BR /&gt;..&lt;BR /&gt;&lt;BR /&gt;Also you can use the typset -i , &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Raj.</description>
      <pubDate>Mon, 12 Sep 2005 04:50:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925167#M408713</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2005-09-12T04:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate input as an integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925168#M408714</link>
      <description>Hi RAC,&lt;BR /&gt;&lt;BR /&gt;I hope you provided the info. But please explain how to limit hours betwwen 1-12 with the case syntax&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;AJi</description>
      <pubDate>Mon, 12 Sep 2005 04:52:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925168#M408714</guid>
      <dc:creator>Aji Thomas</dc:creator>
      <dc:date>2005-09-12T04:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate input as an integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925169#M408715</link>
      <description>Aji ,&lt;BR /&gt;&lt;BR /&gt;its typeset , sory , mistake in my last post.   np pls.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Sep 2005 04:53:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925169#M408715</guid>
      <dc:creator>Raj D.</dc:creator>
      <dc:date>2005-09-12T04:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to validate input as an integer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925170#M408716</link>
      <description>Hi RAC,&lt;BR /&gt;&lt;BR /&gt;I got the logic of the case syntax. Thanks a lot. It helps me to solve the problem&lt;BR /&gt;&lt;BR /&gt;Thanks for the support guys.&lt;BR /&gt;regards,&lt;BR /&gt;AJi</description>
      <pubDate>Mon, 12 Sep 2005 04:56:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-validate-input-as-an-integer/m-p/4925170#M408716</guid>
      <dc:creator>Aji Thomas</dc:creator>
      <dc:date>2005-09-12T04:56:23Z</dc:date>
    </item>
  </channel>
</rss>

