Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2007 10:00 PM
02-19-2007 10:00 PM
I have already found zero for putenv return type.
so why getenv does not return env. variable value.
Thanks,
Subrat
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2007 10:04 PM
02-19-2007 10:04 PM
Re: getenv
could you please include how you are using the putenv/getenv. Please provide list code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2007 10:33 PM
02-19-2007 10:33 PM
Re: getenv
MSP_ListParamByEntity(serverName, entityType, entityName
, MSD_MAXLIST, paramElmArray, startParamName, &returnCount);
if(result != MSE_SUCCESS && result != MSE_SUCCESS_END)break;
for(i = 0;i < returnCount;i++)
{
envVar[0] = '\0';
sprintf(envVar,"%s=%s",
paramElmArray[i].param_name,
paramElmArray[i].param_value);
err = putenv(envVar);
if(err != 0)
{
return MSE_ERROR;
}
}
}
for getenv :
char *lic1;
lic1=getenv("NSIM_ACOL");
//if(lic1!= NULL)
printf("\nLIC_PARAM VALUE:%s",lic1);
MSP_ListParamByEntity get the record from databse and then put in enviorment by putenv.
But when i have call getenv just below after for loop .putenv its return error.
Thanks,
subrat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 12:29 AM
02-20-2007 12:29 AM
Re: getenv
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.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 12:41 AM
02-20-2007 12:41 AM
Re: getenv
I have found err=0 for all variable for putenv.
I have one thing notice that ....
only i found last varibale which is put by putenv.for other its given NULL.
I think its overwrite.
Regards,
subrat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 12:41 AM
02-20-2007 12:41 AM
Re: getenv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 04:08 PM
02-20-2007 04:08 PM
Re: getenv
Ah, exactly. putenv(3) says:
the string pointed to by string becomes part of the environment, so altering the string changes the environment.
>The fix is to use a static storage class local variable or a global variable.
In this case since it is in a for-loop, malloc should be done to have unique strings for each.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 04:21 PM
02-20-2007 04:21 PM
Re: getenv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 04:27 PM
02-20-2007 04:27 PM
Re: getenv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 07:41 PM
02-20-2007 07:41 PM
Re: getenv
Yes. I think you are right.
can you give suggestion for how to allows put in environment more than one variable .
Thanks
Subrat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 08:05 PM
02-20-2007 08:05 PM
SolutionAs 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).
You'll leak if you call MSP_ListParamByEntity with the same paramElmArray[i].param_name.
If you want to solve Clay's "Chapter Two", you can create an STL map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2007 08:17 PM
02-20-2007 08:17 PM
Re: getenv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2007 12:37 AM
02-21-2007 12:37 AM
Re: getenv
A lot of thanks for your help.
Regards,
Subrat