Forum: Ruby tar2rubyscript: getting the path of the original executable

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Patrick G. (Guest)
on 2007-01-23 15:52
Hi,

I try using tar2rubyscript and I need to get the path to the original
executable. oldlocation doesn't seem to help because it referes to the
original working directory. Any idea?

Patrick
Erik V. (Guest)
on 2007-01-23 19:03
(Received via mailing list)
----------------------------------------------------------------

 $ cat application/init.rb
 p $0
 p __FILE__

 $ ruby tar2rubyscript.rb application/
 Creating archive...
 Creating application.rb ...

 $ ruby application.rb
 "...../Temp/tar2rubyscript.d.2900.1/application/init.rb"
 "...../Temp/tar2rubyscript.d.2900.1/application/init.rb"
Patrick G. (Guest)
on 2007-01-23 19:16
Erik V. wrote:
> ----------------------------------------------------------------
>
>  $ cat application/init.rb
>  p $0
>  p __FILE__


Thanks Erik, but obviously I wasn't clear. I need the path to the old
.rb file, the one that is distributed and contains the tar file, not the
one in the temporary directory.

With __FILE__ and $0 I get the new location, with oldlocation I only get
the last PWD and not the location of the tar/rb file.

Patrick
Erik V. (Guest)
on 2007-01-23 19:55
(Received via mailing list)
Sorry, I misunderstood your question...

Currently, it's not possible to determine the path to the RBA.

Mmm...

gegroet,
Erik V. - http://www.erikveen.dds.nl/
Patrick G. (Guest)
on 2007-01-26 11:29
Erik V. wrote:
> Sorry, I misunderstood your question...
>
> Currently, it's not possible to determine the path to the RBA.
>
> Mmm...

Then I have two suggestions for tar2rubyscript:

1) create an environment variable that points to the RBA
2) make the filename 'init.rb' configurable

Thanks in advance,

Patrick
This topic is locked and can not be replied to.