<?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: ksh script needing an interger cmd. line arg in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573697#M857716</link>
    <description>sridhar, below succeeds and f is not an interger&lt;BR /&gt;    echo "f + 5" | bc 2&amp;gt;&amp;amp;1</description>
    <pubDate>Fri, 31 Aug 2001 20:22:00 GMT</pubDate>
    <dc:creator>Marc Ahrendt</dc:creator>
    <dc:date>2001-08-31T20:22:00Z</dc:date>
    <item>
      <title>ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573686#M857705</link>
      <description>what is the best way to test that the 3rd command line argument for my ksh script is a positive interger?&lt;BR /&gt;&lt;BR /&gt;./my_script A B C&lt;BR /&gt;   C needs to be &amp;gt;=0 and an integer&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Aug 2001 17:27:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573686#M857705</guid>
      <dc:creator>Marc Ahrendt</dc:creator>
      <dc:date>2001-08-31T17:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573687#M857706</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;if (( $c &amp;gt;= 0 ))&lt;BR /&gt;then &lt;NEXTBIT&gt;&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Paula&lt;/NEXTBIT&gt;</description>
      <pubDate>Fri, 31 Aug 2001 17:33:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573687#M857706</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2001-08-31T17:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573688#M857707</link>
      <description>Hi Marc,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;you could do something simple like&lt;BR /&gt;&lt;BR /&gt;if [ $3 -gt 0 ]&lt;BR /&gt;then&lt;BR /&gt;   echo "3rd argument greater then 0"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;-Ramesh</description>
      <pubDate>Fri, 31 Aug 2001 17:46:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573688#M857707</guid>
      <dc:creator>linuxfan</dc:creator>
      <dc:date>2001-08-31T17:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573689#M857708</link>
      <description>Hi Marc,&lt;BR /&gt;&lt;BR /&gt;for &amp;gt;=0 change it to&lt;BR /&gt;&lt;BR /&gt;if [ $3 -ge 0 ] &lt;BR /&gt;then &lt;BR /&gt;echo "3rd argument greater then 0" &lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;-Ramesh</description>
      <pubDate>Fri, 31 Aug 2001 17:47:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573689#M857708</guid>
      <dc:creator>linuxfan</dc:creator>
      <dc:date>2001-08-31T17:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573690#M857709</link>
      <description>First I will see if it is an integer or not&lt;BR /&gt;&lt;BR /&gt;echo "$3 + 1 " |bc 2&amp;gt;&amp;amp;1 |grep syntax &amp;gt; /dev/null&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Your C is some character"&lt;BR /&gt;exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;#Once the above is passed, it means it's an integer. Now I will check to see if it is &amp;gt; 0.&lt;BR /&gt;&lt;BR /&gt;if [ $3 -gt 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "C should be greater than 0"&lt;BR /&gt;exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;...code...&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Fri, 31 Aug 2001 17:53:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573690#M857709</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-08-31T17:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573691#M857710</link>
      <description>ooooopsss.. Small correction.. Friday evening.&lt;BR /&gt;&lt;BR /&gt;yaada..yadaa..yadaaa..&lt;BR /&gt;...&lt;BR /&gt;if [ $3 -le 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Arg 3 should be greater than 0"&lt;BR /&gt;exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;...code...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Aug 2001 17:57:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573691#M857710</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-08-31T17:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573692#M857711</link>
      <description>Hi Marc:&lt;BR /&gt;&lt;BR /&gt;Here's one somewhat rigorous way:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#&lt;BR /&gt;typeset X=$3&lt;BR /&gt;#&lt;BR /&gt;[ -z "$X" ] &amp;amp;&amp;amp; { echo "no argument provided";exit 2; }&lt;BR /&gt;#&lt;BR /&gt;[ `expr $X : '[0-9]*'` -ne `expr $X : '.*'` ] &amp;amp;&amp;amp; { echo "not a positive integer"&lt;BR /&gt;;exit 1; }&lt;BR /&gt;#&lt;BR /&gt;[ "$X" -le 0 ] &amp;amp;&amp;amp; { echo "zero not allowed";exit 1; }&lt;BR /&gt;#&lt;BR /&gt;echo "OK"&lt;BR /&gt;exit 0&lt;BR /&gt;#&lt;BR /&gt;#.end.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 31 Aug 2001 19:03:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573692#M857711</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-08-31T19:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573693#M857712</link>
      <description>Hi to all&lt;BR /&gt;&lt;BR /&gt;As I am still learning scripting why use "gt" instead of &amp;gt;= ?&lt;BR /&gt;&lt;BR /&gt;Paula</description>
      <pubDate>Fri, 31 Aug 2001 19:15:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573693#M857712</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2001-08-31T19:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573694#M857713</link>
      <description>Doesn't matter with POSIX. I personally commit syntax errors if I try the symbols like instead &amp;gt;= I type in =&amp;gt; etc., it's more easy to remember gt, ge etc.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Fri, 31 Aug 2001 19:20:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573694#M857713</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-08-31T19:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573695#M857714</link>
      <description>thx for everyone's quick replies&lt;BR /&gt;&lt;BR /&gt;sridhar, your solution does not work reliably for all possible input&lt;BR /&gt;&lt;BR /&gt;james, yours works and is more compact than my crude attempt with grep and regular expressions, but i was hoping there was something built into the shell/test like "if (( -I $3 ))" where I would be that magical test on a number</description>
      <pubDate>Fri, 31 Aug 2001 19:44:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573695#M857714</guid>
      <dc:creator>Marc Ahrendt</dc:creator>
      <dc:date>2001-08-31T19:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573696#M857715</link>
      <description>Marc,&lt;BR /&gt;&lt;BR /&gt;Interesting. Did you have any instance where it couldn't get to work?. That will help me rectify my logic.&lt;BR /&gt; &lt;BR /&gt;-Sri</description>
      <pubDate>Fri, 31 Aug 2001 20:05:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573696#M857715</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-08-31T20:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573697#M857716</link>
      <description>sridhar, below succeeds and f is not an interger&lt;BR /&gt;    echo "f + 5" | bc 2&amp;gt;&amp;amp;1</description>
      <pubDate>Fri, 31 Aug 2001 20:22:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573697#M857716</guid>
      <dc:creator>Marc Ahrendt</dc:creator>
      <dc:date>2001-08-31T20:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script needing an interger cmd. line arg</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573698#M857717</link>
      <description>Didn't have a system infront of me now. But I know where it would be missing. Try this out. &lt;BR /&gt;&lt;BR /&gt;....&lt;BR /&gt;echo "${3}.1 + 1 " |bc 2&amp;gt;&amp;amp;1 |grep syntax &amp;gt; /dev/null &lt;BR /&gt;............&lt;BR /&gt;&lt;BR /&gt;if [ $? = 0 ] &lt;BR /&gt;&lt;BR /&gt;....&lt;BR /&gt;&lt;BR /&gt;Thanks for letting me know.&lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Aug 2001 21:13:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-needing-an-interger-cmd-line-arg/m-p/2573698#M857717</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2001-08-31T21:13:45Z</dc:date>
    </item>
  </channel>
</rss>

