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.
thank you
Roman
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
run.exe
run.exe will be picked up from the modified PATH.
thank you
Roman
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’] = “” #?
ENV[“PATH”] = “/new/path”
Jason Creighton
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.
I recommend that you take a look at ‘shell.rb’, which is part of the
standard distribution. It seems that you may be using Windows
(run.exe), which I have not tested the below on, but I have heard that
shell.rb generally works the same on Windows as on a Unix-based OS.
require ‘shell’
Shell.def_system_command(“command”)
Shell.def_system_command(“command2”)
shell = Shell.cd(“directory”)
shell.transact do
shell.command([args])
shell.command2([args])
end
One of the commands could set an environment variable and another could
run a command line program. For example, ‘shell.env’ lists all
environment variables and ‘shell.env(“LINES=42”)’ will set the LINES
variable to the value 42.
The class method ‘def_system_command’ adds the command given as an
argument as an instance method of all Shell objects. ‘Shell.cd’ creates
a Shell object in the directory given as an argument. ‘shell.transact
do . . . end’ takes advantage of process control functionality built
into the Shell class.
Regards,
Mark
On Tuesday, July 15, 2003, at 04:17 PM, Roman Dolgov 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.
[snip]
thanks Michael.
Where I can find doc about ENV variable (and others)
on internet? (basically where is full spec on ruby
langugage)
I tried to find info on www.ruby-lang.org but
“reference manual” doesn’t say anything about ENV.
thanks
Roman
— Michael Campbell michael_s_campbell@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’] = “” #?
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
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
thanks Michael.
Where I can find doc about ENV variable (and others)
on internet? (basically where is full spec on ruby
langugage)
I tried to find info on www.ruby-lang.org but
“reference manual” doesn’t say anything about ENV.
I use the following quite a lot
-1/ref=sr_8_1/002-9482437-0819239?v=glance&s=books
002-9482437-0819239?v=glance&s=books
and online, http://www.rubycentral.com/book/index.html
For that particular issue, http://www.rubycentral.com/book/rubyworld.html