You are not logged in.

#1 2006-12-31 22:21:21

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Global variables for multiple Bash shells? [Solved.. enough]

Will Bash allow for global variables declared and reset during runtime that can be shared between differnet shells?

Offline

#2 2006-12-31 22:38:50

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: Global variables for multiple Bash shells? [Solved.. enough]

yes. Just export the variable.

export var="foo"

Offline

#3 2006-12-31 22:53:34

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Global variables for multiple Bash shells? [Solved.. enough]

It doesn't work for me:

Shell 1:

[skottish@localhost ~]$ export var="foo"
[skottish@localhost ~]$ echo $var
foo

Shell 2:

[skottish@localhost ~]$ echo $var

Offline

#4 2006-12-31 23:09:12

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: Global variables for multiple Bash shells? [Solved.. enough]

sorry, it only works for the present shell and any other child shells. You could always put it in /etc/profile or ~.bashrc.

Offline

#5 2006-12-31 23:10:38

skymt
Member
Registered: 2006-11-27
Posts: 443

Re: Global variables for multiple Bash shells? [Solved.. enough]

Shells can't intercommunicate. If you want, you can try to hack up an IPC system with FIFOs or sockets (the latter is your best bet, try netcat), but it will be clunky.

May I ask what you're trying to do? There's probably a better way.

Offline

#6 2007-01-01 02:23:03

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: Global variables for multiple Bash shells? [Solved.. enough]

Write it to a file?

Offline

#7 2007-01-01 03:24:35

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: Global variables for multiple Bash shells? [Solved.. enough]

skymt, to make a long story short, I was simply weighing my options of sharing data between two instances of Gimp. Running Gimp-Python scripts from two separate shells gives me true multitasking. The nature of the scripts requires that they are synchronous at all times. I can be a lot less vague if you like, but it's going to be much more wordy than this is :shock:.

I think that pauldonnelly may be on the right track. I was just hoping to avoid adding any more time consuming operations. The frames already take around 50 seconds a piece to generate, and I need 12230 of them. With both cores of my processor running at full strength, that's about 85 hours of render time.

Offline

Board footer

Powered by FluxBB