- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: getenv
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
Discussions
Discussions
Forums
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
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