<?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 Pass Variables to the second script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variables-to-the-second-script/m-p/2838195#M938995</link>
    <description>I would like to write a script that will execute another script by passing variable as parameter. e.g.&lt;BR /&gt;usage s1 a b&lt;BR /&gt;&lt;BR /&gt;#s1&lt;BR /&gt;echo $1 $2&lt;BR /&gt;v=$1&lt;BR /&gt;s2 $v $2&lt;BR /&gt;&lt;BR /&gt;#s2&lt;BR /&gt;echo $1 $2&lt;BR /&gt;&lt;BR /&gt;but the result is null.&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;Stephen</description>
    <pubDate>Mon, 04 Nov 2002 04:35:22 GMT</pubDate>
    <dc:creator>Stephen Ng</dc:creator>
    <dc:date>2002-11-04T04:35:22Z</dc:date>
    <item>
      <title>Pass Variables to the second script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variables-to-the-second-script/m-p/2838195#M938995</link>
      <description>I would like to write a script that will execute another script by passing variable as parameter. e.g.&lt;BR /&gt;usage s1 a b&lt;BR /&gt;&lt;BR /&gt;#s1&lt;BR /&gt;echo $1 $2&lt;BR /&gt;v=$1&lt;BR /&gt;s2 $v $2&lt;BR /&gt;&lt;BR /&gt;#s2&lt;BR /&gt;echo $1 $2&lt;BR /&gt;&lt;BR /&gt;but the result is null.&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;Stephen</description>
      <pubDate>Mon, 04 Nov 2002 04:35:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pass-variables-to-the-second-script/m-p/2838195#M938995</guid>
      <dc:creator>Stephen Ng</dc:creator>
      <dc:date>2002-11-04T04:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Variables to the second script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variables-to-the-second-script/m-p/2838196#M938996</link>
      <description>When a process terminates i.e. script1, it passes back an 'exit status' to it's parent process. An exit status is actually a number between 0 and 255. The shell stores the last exit status it received in the $? metacharacter.&lt;BR /&gt;So adding say exit $? to your script should keep the 'exit status' for the next script.</description>
      <pubDate>Mon, 04 Nov 2002 05:12:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pass-variables-to-the-second-script/m-p/2838196#M938996</guid>
      <dc:creator>Michael Tully</dc:creator>
      <dc:date>2002-11-04T05:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Variables to the second script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variables-to-the-second-script/m-p/2838197#M938997</link>
      <description>Here is a nice piece of code I borrowed.&lt;BR /&gt;&lt;BR /&gt;XXX=`somecommand.sh` &lt;BR /&gt;STAT=$? &lt;BR /&gt;&lt;BR /&gt;Now $STAT is the exit status of somecommand.sh while $XXX contains its output. &lt;BR /&gt;&lt;BR /&gt;This also should be extended to functions within your scripts. &lt;BR /&gt;&lt;BR /&gt;somefunc() &lt;BR /&gt;{ &lt;BR /&gt;FUNCSTAT=0 &lt;BR /&gt;echo "This is somefunc output \c:" &lt;BR /&gt;while [ $# -ge 1 ] &lt;BR /&gt;do &lt;BR /&gt;echo "Arg ${1} \c" &lt;BR /&gt;shift &lt;BR /&gt;done &lt;BR /&gt;echo &lt;BR /&gt;return(${FUNCSTAT}) &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;XXX=`somefunc 111 222` &lt;BR /&gt;STAT=$? &lt;BR /&gt;&lt;BR /&gt;Here the same rules as above apply. Typically, you test the exit(return) status before ever doing anything with the script(function) output. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 04 Nov 2002 05:33:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pass-variables-to-the-second-script/m-p/2838197#M938997</guid>
      <dc:creator>Michael Tully</dc:creator>
      <dc:date>2002-11-04T05:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Variables to the second script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pass-variables-to-the-second-script/m-p/2838198#M938998</link>
      <description>Michael,&lt;BR /&gt;It works.&lt;BR /&gt;Tks,&lt;BR /&gt;Stephen</description>
      <pubDate>Mon, 04 Nov 2002 07:30:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pass-variables-to-the-second-script/m-p/2838198#M938998</guid>
      <dc:creator>Stephen Ng</dc:creator>
      <dc:date>2002-11-04T07:30:47Z</dc:date>
    </item>
  </channel>
</rss>

