Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - Set global environment variable using Setenv/putenv: (7 Items)
   
Set global environment variable using Setenv/putenv  
Hi All,

I tried modifying PATH environment variable using Setenv/putenv but when i exit from the application the values are not 
reflected in the global environment variables. I have a requirement where the global environment variables need to 
updated and should be reflected in the parent shell.

Thanks,
Re: Set global environment variable using Setenv/putenv  
On Mon, Feb 16, 2009 at 09:02:30AM -0500, sathish kumar wrote:
> Hi All,
> 
> I tried modifying PATH environment variable using Setenv/putenv but when i exit from the application the values are 
not reflected in the global environment variables. I have a requirement where the global environment variables need to 
updated and should be reflected in the parent shell.

Changing your environment doesn't affect your parent (the
environment is inherited).  You'd have devise a scheme
whereby the parent would listen for requests to alter its
own environment.

-seanb
Re: Set global environment variable using Setenv/putenv  
Hi.
HOw is it possible to do any modification in the Korne shell (ksh) to reflect the environment variable changes made in 
the child process. In our case the parent in the korne shell (ksh) from where the executables are invoked.

Thanks,
RE: Set global environment variable using Setenv/putenv  
For existing children it`s not possible.  For new children you do an "export VARIABLE=..."

> -----Original Message-----
> From: sathish kumar [mailto:community-noreply@qnx.com]
> Sent: February-16-09 11:20 PM
> To: ostech-core_os
> Subject: Re: Set global environment variable using Setenv/putenv
> 
> Hi.
> HOw is it possible to do any modification in the Korne shell (ksh) to
> reflect the environment variable changes made in the child process. In
> our case the parent in the korne shell (ksh) from where the executables
> are invoked.
> 
> Thanks,
> 
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post22326
> 
Re: Set global environment variable using Setenv/putenv  
Process environment is data which is local to the process. Every process has its *very own* environment, like every 
process has its own, private memory area[s]. 

Parents can not modify their childrens' environments, they can just pass an environment when the child is created; 
children can not modify their parents' envirnoments.

In short: No process can modify any other existing process'es environment.

You will need to find a different approach.

What are you trying to do?
Re: Set global environment variable using Setenv/putenv  
I am trying to return a value from a executable file and use the returned value in Korne shell script. As my return 
values are restricted to 8 bit when i access $? in shell script, i try loading a environment variable in my executable 
and use the environment variable in the shell script to know the return values of my executable.

For example
#./a.out
#echo $PROG_OUTPUT 

Where a.out loads the PROG_OUTPUT with the return value to be used in the shell script.

Thanks
RE: Set global environment variable using Setenv/putenv  

> -----Original Message-----
> From: sathish kumar [mailto:community-noreply@qnx.com]
> Sent: February-17-09 10:39 AM
> To: ostech-core_os
> Subject: Re: Set global environment variable using Setenv/putenv
> 
> I am trying to return a value from a executable file and use the
> returned value in Korne shell script. As my return values are
> restricted to 8 bit when i access $? in shell script, i try loading a
> environment variable in my executable and use the environment variable
> in the shell script to know the return values of my executable.

Have your process "print" the value. And then in the shell do

PROG_OUTPUT=`./a.out`
echo $PROG_OUTPUT


> 
> For example
> #./a.out
> #echo $PROG_OUTPUT
> 
> Where a.out loads the PROG_OUTPUT with the return value to be used in
> the shell script.
> 
> Thanks
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post22351
>