Shell environment variables.

I have two shells one is the parent and one is the child.
Is it possible to change from the child an environmental variable of the parent?
anacletoAsked:
Who is Participating?
 
expert99121199Connect With a Mentor Commented:
The short answer is "no"

In UNIX two separate processes have completely protected variable spaces.  Facilities are provided for programmers to enable the activity you are asking for.  The facilities are called "Inter Process Communication" or IPC.

There are many ways for processes to exchange informaiton, but typically modifying each other's variables is not one of them.  For example, in scripts "Command Substitution" enables the output of a child program to be captured by the parent, and it typically assigned to a variable.  That is the normal method of passing informaiton from child to parent.  Other techniques include disk files, named pipes, and semaphores.

If you describe the problem you are trying to solve, there may be a preferred technique we could recommend.

0
 
ozoCommented:
no
0
 
anacletoAuthor Commented:
I don't have any problem in this, it is just a curiosity.

0
 
vvenksCommented:
yes,you can set the variables of a parent shell available to you in your new shell.for instance at your bourne shell if you give
bash$TERM=vt100
it just sets the term type then if this is followed by "export" command as shown below it can be exported(applied to your new shell)
bash$TERM=vt100
bash$export TERM
Now suppose you give
bash$ sh
$echo $TERM
vt100
try it out.
       

                                                               Bye.
0
 
anacletoAuthor Commented:
For vvenkks:The problem is the opposite.
I've asked to change a parents variable from the child, not viceversa.

Ozo, if you want the points ,make a question, you was the first...
0
All Courses

From novice to tech pro — start learning today.