Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-01-2008, 12:13 PM   #1
Registered: Mar 2007
Distribution: Hardy (Gnome on Ubuntu 8.04) on Compaq N600c laptop
Posts: 323

Rep: Reputation: 30
Environment Variables ( or something similar )

Is there a way to set an env var from one shell in such a way that it is then also "set" (i.e. available, visible, usable, etc.) in another shell?

In other words:

1) open shell 1, (perhaps through gnome-terminal)
2) open shell 2, (same)
3) go to shell 1 and (somehow) set myvar="hello"
4) go to shell 2 and echo myvar
5) see "hello" echoed.


export does not do this.
Old 01-01-2008, 03:56 PM   #2
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
To achieve this, you will have to look at "something similar". You could make som API to do some sort of communication between shells, but it isn't possible to read variables from different shells. There is possibly some sort of communication API out there, somewhere. But as far as I know, there isn't anything build in.
Old 01-01-2008, 06:28 PM   #3
Registered: Mar 2007
Distribution: Hardy (Gnome on Ubuntu 8.04) on Compaq N600c laptop
Posts: 323

Original Poster
Rep: Reputation: 30
Ah. Thanks.

Hmmm ...wait...can't this be done perhaps through pipes? There must be some well established way for processes in one shell to communicate with their neighbors in another.
Old 01-01-2008, 07:00 PM   #4
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 32
There is no way to do this with environment variables as you describe. If the second shell were a child of the first, then using export would allow it to inherit the variable. However, in your scenario, the two shells are unrelated processes so that won't work.

As for communication between processes, yes, there are plenty of ways to do that. Maybe if you tell us what you're trying to accomplish, maybe someone can recommend an appropriate method.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
environment variables slinky2004 Linux - General 4 11-26-2005 09:59 AM
environment variables user_linux Linux - Newbie 3 06-15-2005 08:46 AM
Environment Variables if you su concoran Linux - Newbie 1 08-16-2002 07:18 PM
environment variables da Perp Linux - Newbie 5 01-23-2002 09:34 AM
environment variables aethereal Linux - Newbie 7 12-19-2001 09:34 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration