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?
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.

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

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
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$export TERM
Now suppose you give
bash$ sh
$echo $TERM
try it out.

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...
All Courses

From novice to tech pro — start learning today.