Is there a way to get the path for the Ruby interpreter itself from withing a script? I see rb_argv0 in Ruby 1.6.8 source, however I cannot find the binding to a Ruby constant or some other means to obtain it. Is there any?
which returns the path as an object of class String.
···
On Monday, May 19, 2003, at 11:58 AM, Gennady wrote:
Hi, fellow rubyists
Is there a way to get the path for the Ruby interpreter itself from
withing a script? I see rb_argv0 in Ruby 1.6.8 source, however I
cannot find the binding to a Ruby constant or some other means to
obtain it. Is there any?
Different question: for what do you need this? I ask, because some
methods that create processes accept “-” as a placeholder for the ruby
interpreter. Maybe that solves your problem.
robert
“Gennady” gfb@tonesoft.com schrieb im Newsbeitrag
news:000801c31e1f$3d94fea0$c20ca8c0@gfb…
Hi, fellow rubyists
Is there a way to get the path for the Ruby interpreter itself from
withing a script? I see rb_argv0 in Ruby 1.6.8 source, however I cannot
find the binding to a Ruby constant or some other means to obtain it. Is
there any?
If there isn’t a better Ruby way (if not, there should be), in Linux,
/proc/yourpid/exe points to that executable.
···
On Mon, 2003-05-19 at 10:58, Gennady wrote:
Hi, fellow rubyists
Is there a way to get the path for the Ruby interpreter itself from
withing a script? I see rb_argv0 in Ruby 1.6.8 source, however I
cannot find the binding to a Ruby constant or some other means to
obtain it. Is there any?
Gennady.
–
Tom Felker
Miss work? But my life would be nothing without the nucleon plant.
– Homer, The Simpsons
This works for Unix – I don’t know if it works for Windows, but
would guess that it does.
···
On Monday, May 19, 2003, at 12:36 PM, Mark Wilson wrote:
One way is:
Shell.new.find_system_command(‘ruby’)
which returns the path as an object of class String.
On Monday, May 19, 2003, at 11:58 AM, Gennady wrote:
Hi, fellow rubyists
Is there a way to get the path for the Ruby interpreter itself from
withing a script? I see rb_argv0 in Ruby 1.6.8 source, however I
cannot find the binding to a Ruby constant or some other means to
obtain it. Is there any?
Unfortunatelly, this will give me an interpreter found in the current PATH,
it will not be the right one if the interpreter has been invoked with an
absolute path that is not in PATH variable. I rather need the interpreter
path invoked to handle THIS particular code.
Thanks for suggestion anyway.
Gennady.
···
----- Original Message -----
From: “Mark Wilson” mwilson13@cox.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, May 19, 2003 9:36 AM
Subject: Re: The interpreter path
One way is:
Shell.new.find_system_command(‘ruby’)
which returns the path as an object of class String.
On Monday, May 19, 2003, at 11:58 AM, Gennady wrote:
Hi, fellow rubyists
Is there a way to get the path for the Ruby interpreter itself from
withing a script? I see rb_argv0 in Ruby 1.6.8 source, however I
cannot find the binding to a Ruby constant or some other means to
obtain it. Is there any?
Is there a way to get the path for the Ruby interpreter itself from
withing a script? I see rb_argv0 in Ruby 1.6.8 source, however I
cannot find the binding to a Ruby constant or some other means to
obtain it. Is there any?
Gennady.
If there isn’t a better Ruby way (if not, there should be), in Linux,
/proc/yourpid/exe points to that executable.
Very interesting, I did not know about it. Unfortunatelly I need something
portable that should run at least on Linux and Solaris. A Ruby constant
might be quite handy.
Thank you very much,
Gennady.
···
----- Original Message -----
From: “Tom Felker” tcfelker@mtco.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, May 19, 2003 4:22 PM
Subject: Re: The interpreter path
On Mon, 2003-05-19 at 10:58, Gennady wrote:
–
Tom Felker
Miss work? But my life would be nothing without the nucleon plant.
– Homer, The Simpsons
Unfortunatelly, this will give me an interpreter found in the current PATH,
it will not be the right one if the interpreter has been invoked with an
absolute path that is not in PATH variable. I rather need the interpreter
path invoked to handle THIS particular code.
Unfortunatelly, this will give me an interpreter found in the current
PATH,
it will not be the right one if the interpreter has been invoked with an
absolute path that is not in PATH variable. I rather need the
interpreter
path invoked to handle THIS particular code.
As far as I understand it holds values the interpreter has been compiled
with. They will be the same no matter where you place the ruby executable
afterwards. And I am interested in an invocation path.
I am using Ruby for our product installation. I place the interpreter and a
part of Ruby system library into the package together with other product
files. During installation I need to invoke a ruby script (via a boot-strap
shell script) right form a CD or whatever location a package is extracted
into (a target host is not required to have Ruby installed).
The first thing I have to do in my Ruby script is to adjust LOAD_PATH
relative to the interpreter invocation path. So I hoped that some constant
is available for this. I found nothing of the kind so far.
Actually, I figured out another way to do the job. However I still think it
would be nice to have this feature in Ruby.
Thanks to all responders,
Gennady.
···
----- Original Message -----
From: “Simon Strandgaard” 0bz63fz3m1qt3001@sneakemail.com
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, May 19, 2003 12:28 PM
Subject: Re: The interpreter path
On Tue, 20 May 2003 02:54:49 +0900, Gennady wrote: