<?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: getenv in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947828#M97691</link>
    <description>Okay, good point about dynamically allocating the memory -- but it's up to you to make sure there are no memory leaks now --- and that's Chapter Two.</description>
    <pubDate>Wed, 21 Feb 2007 00:21:10 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2007-02-21T00:21:10Z</dc:date>
    <item>
      <title>getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947821#M97684</link>
      <description>I have problem with getenv since its return NUll for a Environment variable.&lt;BR /&gt;I have already found zero for putenv return type.&lt;BR /&gt;so why getenv does not return env. variable value.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Subrat&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Feb 2007 06:00:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947821#M97684</guid>
      <dc:creator>subrat chaudhary</dc:creator>
      <dc:date>2007-02-20T06:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947822#M97685</link>
      <description>Subrat,&lt;BR /&gt;could you please include how you are using the putenv/getenv. Please provide list code.</description>
      <pubDate>Tue, 20 Feb 2007 06:04:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947822#M97685</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-02-20T06:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947823#M97686</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt; MSP_ListParamByEntity(serverName, entityType, entityName&lt;BR /&gt;         , MSD_MAXLIST, paramElmArray, startParamName, &amp;amp;returnCount);&lt;BR /&gt;&lt;BR /&gt;      if(result != MSE_SUCCESS &amp;amp;&amp;amp; result != MSE_SUCCESS_END)break;&lt;BR /&gt;&lt;BR /&gt;      for(i = 0;i &amp;lt; returnCount;i++)&lt;BR /&gt;      {&lt;BR /&gt;       envVar[0] = '\0';&lt;BR /&gt;       sprintf(envVar,"%s=%s",&lt;BR /&gt;          paramElmArray[i].param_name,&lt;BR /&gt;          paramElmArray[i].param_value);   &lt;BR /&gt;       &lt;BR /&gt;       err = putenv(envVar);&lt;BR /&gt;       if(err != 0)&lt;BR /&gt;       {&lt;BR /&gt;            return MSE_ERROR;&lt;BR /&gt;       }&lt;BR /&gt;      }&lt;BR /&gt;   }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for getenv :&lt;BR /&gt;char *lic1;&lt;BR /&gt;&lt;BR /&gt; lic1=getenv("NSIM_ACOL");&lt;BR /&gt;     //if(lic1!= NULL)&lt;BR /&gt;     printf("\nLIC_PARAM VALUE:%s",lic1);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;MSP_ListParamByEntity get the record from databse and then put in enviorment by putenv.&lt;BR /&gt;&lt;BR /&gt;But when i have call getenv just below after for loop .putenv its return error.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;subrat</description>
      <pubDate>Tue, 20 Feb 2007 06:33:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947823#M97686</guid>
      <dc:creator>subrat chaudhary</dc:creator>
      <dc:date>2007-02-20T06:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947824#M97687</link>
      <description>Hi Subrat:&lt;BR /&gt;&lt;BR /&gt;In addition to checking the return value from 'putenv()', you ought to print the value of 'errno'.  'putenv()' can fail with ENOMEM or EILSEQ --- insufficient space to exnpand the environment, or an invalid multibyte character sequence.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 20 Feb 2007 08:29:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947824#M97687</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-02-20T08:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947825#M97688</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have found err=0 for all variable for putenv.&lt;BR /&gt;&lt;BR /&gt;I have one thing notice that ....&lt;BR /&gt;only i found last varibale which is put by putenv.for other its given NULL.&lt;BR /&gt;&lt;BR /&gt;I think its overwrite.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;subrat&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Feb 2007 08:41:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947825#M97688</guid>
      <dc:creator>subrat chaudhary</dc:creator>
      <dc:date>2007-02-20T08:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947826#M97689</link>
      <description>I don't see where envVar is declared but an extremely common problem is to call putenv() with an auto storage class local variable inside a function. When the variable goes out of scope the environment is no longer defined. The fix is to use a static storage class local variable or a global variable.</description>
      <pubDate>Tue, 20 Feb 2007 08:41:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947826#M97689</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-02-20T08:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947827#M97690</link>
      <description>&amp;gt;Clay: I don't see where envVar is declared&lt;BR /&gt;&lt;BR /&gt;Ah, exactly.  putenv(3) says:&lt;BR /&gt;the string pointed to by string becomes part of the environment, so altering the string changes the environment.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;The fix is to use a static storage class local variable or a global variable.&lt;BR /&gt;&lt;BR /&gt;In this case since it is in a for-loop, malloc should be done to have unique strings for each.</description>
      <pubDate>Wed, 21 Feb 2007 00:08:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947827#M97690</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-02-21T00:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947828#M97691</link>
      <description>Okay, good point about dynamically allocating the memory -- but it's up to you to make sure there are no memory leaks now --- and that's Chapter Two.</description>
      <pubDate>Wed, 21 Feb 2007 00:21:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947828#M97691</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-02-21T00:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947829#M97692</link>
      <description>... and now that I've thought about it, maybe a single static variable for multiple putenv()'s ain't such a bad idea because the observed behavior of the code would be interesting and point to the correct approach.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Feb 2007 00:27:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947829#M97692</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-02-21T00:27:17Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947830#M97693</link>
      <description>Hi Clay&lt;BR /&gt;&lt;BR /&gt;Yes. I think you are right.&lt;BR /&gt;can you give suggestion for how to allows put in environment more than one variable .&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Subrat</description>
      <pubDate>Wed, 21 Feb 2007 03:41:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947830#M97693</guid>
      <dc:creator>subrat chaudhary</dc:creator>
      <dc:date>2007-02-21T03:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947831#M97694</link>
      <description>&amp;gt;can you give suggestion for how to allows put in environment more than one variable .&lt;BR /&gt;&lt;BR /&gt;As I said, just call strdup(3) then putenv(3).  And ignore the fact that you may leak if you are setting the same variable with putenv(3).&lt;BR /&gt;&lt;BR /&gt;You'll leak if you call MSP_ListParamByEntity with the same paramElmArray[i].param_name.&lt;BR /&gt;&lt;BR /&gt;If you want to solve Clay's "Chapter Two", you can create an STL map&lt;CONST char=""&gt;.  Where the key is .param_name and the value is the result of strdup.  If you find the name in your map and strlen of previous value is &amp;gt;= new value, you can just overwrite it and not call putenv.  If not, strdup and putenv, the free the old space and update your map.  (You could store the length in the map too.)&lt;BR /&gt;&lt;/CONST&gt;</description>
      <pubDate>Wed, 21 Feb 2007 04:05:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947831#M97694</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-02-21T04:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947832#M97695</link>
      <description>Oops, I mistakenly assumed that you were using C++.  If not, ignore the mention of STL.  You would have to invent your own data structure to keep track of leaks.</description>
      <pubDate>Wed, 21 Feb 2007 04:17:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947832#M97695</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-02-21T04:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: getenv</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947833#M97696</link>
      <description>Hi Dennis,&lt;BR /&gt;&lt;BR /&gt;A lot of thanks for your help.&lt;BR /&gt;Regards,&lt;BR /&gt;Subrat</description>
      <pubDate>Wed, 21 Feb 2007 08:37:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getenv/m-p/3947833#M97696</guid>
      <dc:creator>subrat chaudhary</dc:creator>
      <dc:date>2007-02-21T08:37:44Z</dc:date>
    </item>
  </channel>
</rss>

