<?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: scripting question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157833#M901928</link>
    <description>Hi Umapathy,&lt;BR /&gt;    Thanks for the suggestion! Will try that.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;tenghin</description>
    <pubDate>Wed, 07 Jan 2004 06:20:10 GMT</pubDate>
    <dc:creator>yap</dc:creator>
    <dc:date>2004-01-07T06:20:10Z</dc:date>
    <item>
      <title>scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157823#M901918</link>
      <description>Hi,&lt;BR /&gt;   How can I put argument as variable in script? Such as:&lt;BR /&gt;&lt;BR /&gt;If first argument to a script is "Arg1". If I do&lt;BR /&gt;&lt;BR /&gt;x=1&lt;BR /&gt;echo $($x)&lt;BR /&gt;&lt;BR /&gt;Can I get "Arg1" to print out? I know this is not the correct way to do. Anyone can point out the right way? Thanks.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;tenghin</description>
      <pubDate>Wed, 07 Jan 2004 05:15:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157823#M901918</guid>
      <dc:creator>yap</dc:creator>
      <dc:date>2004-01-07T05:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157824#M901919</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;x=$1&lt;BR /&gt;echo $($x)&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Bernhard</description>
      <pubDate>Wed, 07 Jan 2004 05:21:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157824#M901919</guid>
      <dc:creator>Bernhard Mueller</dc:creator>
      <dc:date>2004-01-07T05:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157825#M901920</link>
      <description>The arguments are passed as $n where n is 1, 2, 3...&lt;BR /&gt;&lt;BR /&gt;You can capture them as $1, $2 etc.  You can use them as any other variable.&lt;BR /&gt;&lt;BR /&gt;echo $1 &lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Umapathy</description>
      <pubDate>Wed, 07 Jan 2004 05:25:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157825#M901920</guid>
      <dc:creator>Umapathy S</dc:creator>
      <dc:date>2004-01-07T05:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157826#M901921</link>
      <description>Hi Bernhard,&lt;BR /&gt;      Thanks for the reply. The reason I want to make the argument as variable is because sometime the position of argument can change, may be first argument, may be second. So I don't think your suggestion can work. Do you have other suggestion ?&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;tenghin</description>
      <pubDate>Wed, 07 Jan 2004 05:32:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157826#M901921</guid>
      <dc:creator>yap</dc:creator>
      <dc:date>2004-01-07T05:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157827#M901922</link>
      <description>If your command is as "./myscript arg1", then you can get the value arg1 inside your script using $1 ($2, $3, ... for 2nd, 3rd,... parameters).&lt;BR /&gt;&lt;BR /&gt;echo $1&lt;BR /&gt;=&amp;gt; arg1&lt;BR /&gt;&lt;BR /&gt;If $arg1 is a parameter ($arg1=value1), then you can do :&lt;BR /&gt;eval echo \${$1}&lt;BR /&gt;=&amp;gt; value1&lt;BR /&gt;&lt;BR /&gt;marc.</description>
      <pubDate>Wed, 07 Jan 2004 05:37:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157827#M901922</guid>
      <dc:creator>marc seguin</dc:creator>
      <dc:date>2004-01-07T05:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157828#M901923</link>
      <description>Tenghin,&lt;BR /&gt;  At some point you have to identify what that incoming argument means.  At that same point you can assign them to your variable of choice.&lt;BR /&gt;&lt;BR /&gt;  I dont find any problem here.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Umapathy</description>
      <pubDate>Wed, 07 Jan 2004 05:41:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157828#M901923</guid>
      <dc:creator>Umapathy S</dc:creator>
      <dc:date>2004-01-07T05:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157829#M901924</link>
      <description>Hi Marc,&lt;BR /&gt;    Thanks a lot. That is just what I want.&lt;BR /&gt;&lt;BR /&gt;Umapathy,&lt;BR /&gt;    Thanks for you reply also.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks guys!!&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;tenghin</description>
      <pubDate>Wed, 07 Jan 2004 05:42:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157829#M901924</guid>
      <dc:creator>yap</dc:creator>
      <dc:date>2004-01-07T05:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157830#M901925</link>
      <description>Hi Thenghin,&lt;BR /&gt;&lt;BR /&gt;so I guess you want something like&lt;BR /&gt;&lt;BR /&gt;./script -1 arg1 -2 arg2&lt;BR /&gt;would work exactly like&lt;BR /&gt;./script -2 arg2 -1 arg1&lt;BR /&gt;&lt;BR /&gt;???&lt;BR /&gt;&lt;BR /&gt;then you would use a case statement and use shift for each $1 to read each script argument sequentially and set variables according to whether -1 -2 etc have been found until you have gone through the whole command line.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Bernhard&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Jan 2004 05:46:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157830#M901925</guid>
      <dc:creator>Bernhard Mueller</dc:creator>
      <dc:date>2004-01-07T05:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157831#M901926</link>
      <description>Hi Bernhard,&lt;BR /&gt;    Actually what I want is assign the second last argument to a variable, such as :&lt;BR /&gt;&lt;BR /&gt;x=$#&lt;BR /&gt;y=`expr $x - 1`&lt;BR /&gt;h=`eval echo \${$y}`&lt;BR /&gt;echo $h&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I can do "eval echo \${$y}" alone but cannot assign to variable h as above.Any idea anyone ?&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;tenghin</description>
      <pubDate>Wed, 07 Jan 2004 05:56:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157831#M901926</guid>
      <dc:creator>yap</dc:creator>
      <dc:date>2004-01-07T05:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157832#M901927</link>
      <description>Tenghin,&lt;BR /&gt;  One way to do is to use the shift.  Go on shifting till last but one.  &lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Umapathy</description>
      <pubDate>Wed, 07 Jan 2004 06:09:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157832#M901927</guid>
      <dc:creator>Umapathy S</dc:creator>
      <dc:date>2004-01-07T06:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157833#M901928</link>
      <description>Hi Umapathy,&lt;BR /&gt;    Thanks for the suggestion! Will try that.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;tenghin</description>
      <pubDate>Wed, 07 Jan 2004 06:20:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157833#M901928</guid>
      <dc:creator>yap</dc:creator>
      <dc:date>2004-01-07T06:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157834#M901929</link>
      <description>Specifically&lt;BR /&gt; &lt;BR /&gt;x=$#&lt;BR /&gt;(( y = x - 1 ))&lt;BR /&gt;while [ $y -gt 1 ]&lt;BR /&gt;do&lt;BR /&gt;        shift&lt;BR /&gt;        (( y = y - 1 ))&lt;BR /&gt;done&lt;BR /&gt;echo $1&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Jan 2004 06:21:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157834#M901929</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-01-07T06:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157835#M901930</link>
      <description>Aha,&lt;BR /&gt;&lt;BR /&gt;actuall $# will give you the number of arguments, so that you can evalute $(($#-1))&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Bernhard</description>
      <pubDate>Wed, 07 Jan 2004 06:35:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157835#M901930</guid>
      <dc:creator>Bernhard Mueller</dc:creator>
      <dc:date>2004-01-07T06:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157836#M901931</link>
      <description>Be careful, use braces because you don't know how many parameters you'll get.&lt;BR /&gt;&lt;BR /&gt;1st parameter : $1 or ${1}&lt;BR /&gt;12th parameter : ${12}&lt;BR /&gt;&lt;BR /&gt;$12 is unknown (or, in fact, ${1} with a 2 at the end)&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Jan 2004 07:02:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157836#M901931</guid>
      <dc:creator>marc seguin</dc:creator>
      <dc:date>2004-01-07T07:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157837#M901932</link>
      <description>Hi Mark,&lt;BR /&gt;    Thanks for the script. It works but I don't what are the lines "((y=x-1))" and "((y=y-1))" for ? and why we need double brackets for these lines? Sorry if I ask dumb question, I'm a newbie in scripting :).&lt;BR /&gt;&lt;BR /&gt;Bernhard,&lt;BR /&gt;    Thanks for your suggestion. But when I do&lt;BR /&gt;"eval $(($#-1))" in script, it gaves error. Would you mind show me the right command line? Thanks.&lt;BR /&gt;&lt;BR /&gt;Marc,&lt;BR /&gt;    Thanks for your tips!&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;tenghin</description>
      <pubDate>Wed, 07 Jan 2004 21:11:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157837#M901932</guid>
      <dc:creator>yap</dc:creator>
      <dc:date>2004-01-07T21:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157838#M901933</link>
      <description>the short way would be to do&lt;BR /&gt;h=$(eval echo \${$(($#-1))})&lt;BR /&gt;&lt;BR /&gt;but&lt;BR /&gt;&lt;BR /&gt;if (( $# &amp;lt; 2 )) ;then&lt;BR /&gt;print "not enough args"&lt;BR /&gt;exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;#create array of command line arguments&lt;BR /&gt;set -A parms $*  &lt;BR /&gt;(( x=$#-1 ))    #x=second to last argument&lt;BR /&gt;h=${parms[$x]   #h=value of second to last arugment&lt;BR /&gt;&lt;BR /&gt;is easier to understand</description>
      <pubDate>Wed, 07 Jan 2004 21:47:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157838#M901933</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-01-07T21:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157839#M901934</link>
      <description>It works but I don't what are the lines "((y=x-1))" and "((y=y-1))" for ? and why we need double brackets for these lines?&lt;BR /&gt;&lt;BR /&gt;the syntax ((...)) does arthmetic evaluation&lt;BR /&gt;&lt;BR /&gt;(( y=y-1)) subtracts 1 from y and assigns that value to the variable y.&lt;BR /&gt;actually it should be (( y=$y-1))</description>
      <pubDate>Wed, 07 Jan 2004 21:54:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157839#M901934</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-01-07T21:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157840#M901935</link>
      <description>(( x=$#-1 )) #x=second to last argument&lt;BR /&gt;h=${parms[$x] #h=value of second to last arugment&lt;BR /&gt;&lt;BR /&gt;being the array index starts at zero the above actually gives last argument and i forgot the ending brace. so this is what works&lt;BR /&gt;&lt;BR /&gt;(( x=$#-2 ))   #x=second to last argument&lt;BR /&gt;h=${parms[$x]} #h=value of second to last arugment&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Jan 2004 22:07:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157840#M901935</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-01-07T22:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157841#M901936</link>
      <description>Hi Curt,&lt;BR /&gt;    Thanks a lot. Your first suggestion is the easier way for my need. Also thanks for explanation on the double brackets.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Again thanks to everyone for providing me with such useful tips and explanations. I sure learn a lot of things from this thread :)&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;tenghin</description>
      <pubDate>Wed, 07 Jan 2004 22:48:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157841#M901936</guid>
      <dc:creator>yap</dc:creator>
      <dc:date>2004-01-07T22:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157842#M901937</link>
      <description>Actually curt, Within the double brackets, the $ is not required.  Personally, I think it's a mistake as it makes it inconsistent with every other time you reference a variable but it saves on a bit of typing.</description>
      <pubDate>Thu, 08 Jan 2004 03:22:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3157842#M901937</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2004-01-08T03:22:46Z</dc:date>
    </item>
  </channel>
</rss>

