robert ehteshamzadeh
7/16/2003 5:47:00 AM
When you run a ruby script, ruby is a child process of your shell.
On Windows it looks like this:
explorer.exe
cmd.exe (shell)
ruby.exe
each exe has it''s own environment. It inherits the environment of it''s
parent, and can
change it''s own environment but not it''s parent''s env.
so you can change the shell''s environment with a shell script ( or batch
file )
and you can change the environment of a script while it''s running by
puts ENV["PATH"] # shows "/old/path"
ENV["PATH"] = "/new/path"
puts ENV["PATH"] # shows "/new/path"
but if you echo the env var after the script has finished, you will still
see the old path.
If you wish to change the environment of the shell, you must do it with a
shell script (batch file).
"Jason Creighton" <androflux@softhome.net.remove.to.reply> wrote in message
news:20030715225659.443b6445.androflux@softhome.net.remove.to.reply...
> On Wed, 16 Jul 2003 05:17:11 +0900
> Roman Dolgov <roman_dolgov@yahoo.com> wrote:
>
> > Hi All,
> >
> > Is there any way to change enviroment variable during
> > execution of ruby script inside of the script.
> >
> > (for ex PATH )
> >
> > So when I use `` command
> >
> > # change PATH somehow
> > `run.exe`
> >
> > run.exe will be picked up from the modified PATH.
>
> ENV["PATH"] = "/new/path"
>
> Jason Creighton
>