Set ENV on different session

M

Matti

Hello,

I need to set an Environment Variable which will be used by a script
started in a different session (not child process of the script which
has set the Env). So I need something like "exporting" the environment
setting I performed in my perl script. Is this somehow possible?

Thanks,

AndyW.
 
J

Juha Laiho

(e-mail address removed) (Matti) said:
I need to set an Environment Variable which will be used by a script
started in a different session (not child process of the script which
has set the Env). So I need something like "exporting" the environment
setting I performed in my perl script. Is this somehow possible?

You cannot force such changes upon an unrelated process (without
co-operation of the said process). What you could do is to arrange some
form or IPC (interprocess communication) between the two processes; the
simplest form being to have the first process write a file with the
desired settings, and making the other process to check for the file
existence and read it at the appropriate point in execution.
 
S

Scott W Gifford

I need to set an Environment Variable which will be used by a script
started in a different session (not child process of the script
which has set the Env). So I need something like "exporting" the
environment setting I performed in my perl script. Is this somehow
possible?

A common way to do this is to simply print the environment variables
that should be set, and let a shell handle the environment. For
example, with a Bourne-like shell, you could do something like:

`perl -le'print "export test=hi"'`

to set the variable "test" to "hi". To make this less annoying, you
can use shell functions which will handle calling the script and
putting all of the quotes in the right place.

You could do the same thing from within another program, but you'd
have to parse the output of the script and set the environment
variables yourself.

-----ScottG.
 
B

Ben Morrow

Quoth (e-mail address removed) (Matti):
I need to set an Environment Variable which will be used by a script
started in a different session (not child process of the script which
has set the Env). So I need something like "exporting" the environment
setting I performed in my perl script. Is this somehow possible?

This depends on your system... under Unix systems, you'll need to insert
entries in ~/.profile or ~/.login (or maybe somewhere else) depending on
the user's shell; under WinNT you need to put it in the appropriate
place in the registry (sorry, not sure where this is: set an env var and
have a poke around till you find it); under DOS/Win9x you need to insert
an entry into AUTOEXEC.BAT. I don't know about other systems, but I'd
guess it's usually possible.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,154
Messages
2,570,870
Members
47,400
Latest member
FloridaFvt

Latest Threads

Top