<?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: problem with global variables in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509410#M705407</link>
    <description>hi and thanks,&lt;BR /&gt;there are no parsing between scripts, only between diffrent function on the same script.&lt;BR /&gt;the thing is, there are varibles that defined first out of the function (globbaly) (1) , than one function use this variable (2), then main proggram use it again (3), and then another function use this variable (4).&lt;BR /&gt;sometimes, i see varible that was defined in (2) and won't be recognize at (3) or in (4).&lt;BR /&gt;</description>
    <pubDate>Tue, 22 Mar 2005 08:12:47 GMT</pubDate>
    <dc:creator>itai weisman</dc:creator>
    <dc:date>2005-03-22T08:12:47Z</dc:date>
    <item>
      <title>problem with global variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509408#M705403</link>
      <description>hello everyone,&lt;BR /&gt;I'm trying to automate the procedure of adding nodes to my enviorment by writing a script.&lt;BR /&gt;for some reason, i'm not able to use global variables, in some parts of the script.&lt;BR /&gt;I have no idea why, the global variable {ExitCode} and {NODE_TYPE}, won't be updated in the outside the function.&lt;BR /&gt;since NODE_TYPE contains the value for 'mach_type' parameter of opcnode command,&lt;BR /&gt;AddToDB function fails, and since ExitCode variable updated on the function is not updated globally, test for {ExitCode} (line 289), that excute from main, succeed (while its suppose to fail)&lt;BR /&gt;attached tar file that contains the script and parameter file (if you try to run the script, modify OVO_SERVER parameter - set on line 30&lt;BR /&gt;thanks ppl</description>
      <pubDate>Tue, 22 Mar 2005 07:55:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509408#M705403</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2005-03-22T07:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: problem with global variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509409#M705406</link>
      <description>I know there are problems passing variables between scripts depending on how the shell is forked.&lt;BR /&gt;&lt;BR /&gt;Is the problem that the variable don't make it from the parent to the child or that they aren't returned from the child to the parent ?&lt;BR /&gt;&lt;BR /&gt;If it's that they are not going from the parent to the child, then you may need to manually "source" the variable file (i.e. if it were a global networking variable then add:&lt;BR /&gt;. /etc/rc.config.d/netconf  to the script).&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Mar 2005 08:02:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509409#M705406</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2005-03-22T08:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: problem with global variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509410#M705407</link>
      <description>hi and thanks,&lt;BR /&gt;there are no parsing between scripts, only between diffrent function on the same script.&lt;BR /&gt;the thing is, there are varibles that defined first out of the function (globbaly) (1) , than one function use this variable (2), then main proggram use it again (3), and then another function use this variable (4).&lt;BR /&gt;sometimes, i see varible that was defined in (2) and won't be recognize at (3) or in (4).&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Mar 2005 08:12:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509410#M705407</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2005-03-22T08:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: problem with global variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509411#M705409</link>
      <description>itai,&lt;BR /&gt;&lt;BR /&gt;I was able to duplicate your problem with the following script.&lt;BR /&gt;#&lt;BR /&gt;#! /bin/sh&lt;BR /&gt;func1()&lt;BR /&gt;{&lt;BR /&gt;Code=1&lt;BR /&gt;return 0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;func2()&lt;BR /&gt;{&lt;BR /&gt;Code=2&lt;BR /&gt;return 0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;func3()&lt;BR /&gt;{&lt;BR /&gt;Code=3&lt;BR /&gt;return 0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;func4()&lt;BR /&gt;{&lt;BR /&gt;Code=4&lt;BR /&gt;func3&lt;BR /&gt;return 0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for arg in func1 func2 func3 func4&lt;BR /&gt;do&lt;BR /&gt;$arg | tee -a xxx&lt;BR /&gt;echo "${Code}"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I was able to make it work with the following  changes:&lt;BR /&gt;&lt;BR /&gt;(for arg in func1 func2 func3 func4&lt;BR /&gt;do&lt;BR /&gt;$arg&lt;BR /&gt;echo "${Code}"&lt;BR /&gt;done) | tee -a xxx&lt;BR /&gt;&lt;BR /&gt;Hope this helps you in figuring out how to modify your script.&lt;BR /&gt;&lt;BR /&gt;Rory&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Mar 2005 11:12:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509411#M705409</guid>
      <dc:creator>Rory R Hammond</dc:creator>
      <dc:date>2005-03-23T11:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: problem with global variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509412#M705411</link>
      <description>hi Rory and thanks,&lt;BR /&gt;i don't understand.. where did you put the braces? &lt;BR /&gt;(i see a closer after done )&lt;BR /&gt;where would you do the return code ( $? ) test?&lt;BR /&gt;what about other global parameter that wont be updated? or sometimes being update and sometimes not? maybe i don't use global variable correctly?&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Mar 2005 11:42:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509412#M705411</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2005-03-23T11:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: problem with global variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509413#M705412</link>
      <description>&lt;BR /&gt;itai,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; ( for ... done )|tee -a filename&lt;BR /&gt;&lt;BR /&gt;I think the tee is causing a forked process (child) and the child is not able to update the parents variables.&lt;BR /&gt;&lt;BR /&gt;A another solution would be to update the exetcodes to a tmp exitcode file. then read the results from the file.&lt;BR /&gt;You would have to remove the file after shell completion or when trapped.&lt;BR /&gt;&lt;BR /&gt;Hope that helps&lt;BR /&gt;&lt;BR /&gt;rory&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Mar 2005 12:20:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-with-global-variables/m-p/3509413#M705412</guid>
      <dc:creator>Rory R Hammond</dc:creator>
      <dc:date>2005-03-23T12:20:39Z</dc:date>
    </item>
  </channel>
</rss>

