<?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 validate script args in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746532#M722045</link>
    <description>I have a script which takes an argument that represents the number of hours to run a process for.  I want to make sure the arg is between 1 and 24.  I know I could do some if statements but I was wondering if there was a better way, maybe with RE's, to do this.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Greg</description>
    <pubDate>Mon, 17 Jun 2002 19:35:58 GMT</pubDate>
    <dc:creator>Greg Stark_1</dc:creator>
    <dc:date>2002-06-17T19:35:58Z</dc:date>
    <item>
      <title>validate script args</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746532#M722045</link>
      <description>I have a script which takes an argument that represents the number of hours to run a process for.  I want to make sure the arg is between 1 and 24.  I know I could do some if statements but I was wondering if there was a better way, maybe with RE's, to do this.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Greg</description>
      <pubDate>Mon, 17 Jun 2002 19:35:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746532#M722045</guid>
      <dc:creator>Greg Stark_1</dc:creator>
      <dc:date>2002-06-17T19:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: validate script args</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746533#M722046</link>
      <description>!/bin/sh&lt;BR /&gt;if [ $VAR -ge 1 -a $VAR -le 24 ]&lt;BR /&gt;  then&lt;BR /&gt;    echo "good"&lt;BR /&gt;  else&lt;BR /&gt;    echo "no good"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;GL,&lt;BR /&gt;C</description>
      <pubDate>Mon, 17 Jun 2002 19:44:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746533#M722046</guid>
      <dc:creator>Craig Rants</dc:creator>
      <dc:date>2002-06-17T19:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: validate script args</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746534#M722047</link>
      <description>Using &amp;gt; and &amp;lt; to compare will always be faster than whatever regular expression could be generated.&lt;BR /&gt;&lt;BR /&gt;If you really wanted a reg express, then&lt;BR /&gt;[1-9]|1[0-9]|2[0-4]&lt;BR /&gt;&lt;BR /&gt;could be used in an "extend reg expressoin", like-&lt;BR /&gt;case "11" in  [1-9]|1[0-9]|2[0-4])e cho "yes" ;;&lt;BR /&gt; *) echo "no" ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 17 Jun 2002 19:49:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746534#M722047</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-06-17T19:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: validate script args</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746535#M722048</link>
      <description>iHere's is one approach using command-line perl RE's:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;STAT=1&lt;BR /&gt;until [ ${STAT} -eq 0 ]&lt;BR /&gt;  do&lt;BR /&gt;     echo "Enter Hour: \c"&lt;BR /&gt;     read HR&lt;BR /&gt;     perl -e 'if ($ARGV[0] =~ /^\d+$/) { if ($ARGV[0] &amp;gt;= 0 &amp;amp;&amp;amp; $ARGV[0] &amp;lt;= 24) {exit(0)}}; exit(1);' ${HR}&lt;BR /&gt;     STAT=$?&lt;BR /&gt;     if [ ${STAT} -ne 0 ]&lt;BR /&gt;       then&lt;BR /&gt;         echo "\07BAD INPUT"&lt;BR /&gt;       fi&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt;If I didn't make a typo that should be a complete solution.&lt;BR /&gt;</description>
      <pubDate>Mon, 17 Jun 2002 20:04:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746535#M722048</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-06-17T20:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: validate script args</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746536#M722049</link>
      <description>I'm an idiot. Change the $ARGV[0] &amp;gt;= 0 to $ARGV[0] &amp;gt; 0.</description>
      <pubDate>Mon, 17 Jun 2002 20:07:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746536#M722049</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-06-17T20:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: validate script args</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746537#M722050</link>
      <description>Clay,&lt;BR /&gt;&lt;BR /&gt;You're being too hard on yourself. Idiots don't get to be Olympians!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;:-)&lt;BR /&gt;Marty</description>
      <pubDate>Mon, 17 Jun 2002 20:13:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746537#M722050</guid>
      <dc:creator>Martin Johnson</dc:creator>
      <dc:date>2002-06-17T20:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: validate script args</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746538#M722051</link>
      <description>You must all be SysAdmins -- you are making this way too difficult.  Korn/POSIX will accept:&lt;BR /&gt;&lt;BR /&gt;        if (( ${1} &amp;gt; 0 &amp;amp;&amp;amp; ${1} &amp;lt; 25 ))&lt;BR /&gt;        then&lt;BR /&gt;                echo $I is OK&lt;BR /&gt;        else&lt;BR /&gt;                echo $I is wrong&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;Yes, those are double-parenthesis.  They are also good for incrementing variables like this:&lt;BR /&gt;&lt;BR /&gt;    (( VAR += 1 ))&lt;BR /&gt;&lt;BR /&gt;Be careful preceeding them with "$" because they are arithmetic evaluations.&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;-dlt-&lt;BR /&gt;&lt;BR /&gt;BTW:  [ ] causes the shell to load test(1) to make the decision; using [[ ]] will avoid the overhead of loading test(1) and put the burden on the quite capable shell.</description>
      <pubDate>Tue, 18 Jun 2002 14:40:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746538#M722051</guid>
      <dc:creator>David Totsch</dc:creator>
      <dc:date>2002-06-18T14:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: validate script args</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746539#M722052</link>
      <description>Now hold on a minute, David. I will certainly concede that your approach will work but if and only if, it's given a valid numeric operand. A far safer approach is to make sure that the user supplied numeric data before doing any numeric comparisons. Craig's solution suffers from the same weakness.&lt;BR /&gt;&lt;BR /&gt;Your point about [[ in lieu of [ is well taken.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Jun 2002 15:11:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746539#M722052</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-06-18T15:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: validate script args</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746540#M722053</link>
      <description>He also stated he was interested in a version that had a regular expression. The great thing about the forum is we get to see more than one way to do it...&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 18 Jun 2002 16:52:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/validate-script-args/m-p/2746540#M722053</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-06-18T16:52:26Z</dc:date>
    </item>
  </channel>
</rss>

