# Tar2rubyscript: getting the path of the original executable

**URL:** <https://www.ruby-forum.com/t/tar2rubyscript-getting-the-path-of-the-original-executable/83068>\
**Category:** Ruby\
**Created:** [January 23, 2007, 2:52pm UTC](https://www.ruby-forum.com/t/tar2rubyscript-getting-the-path-of-the-original-executable/83068 "2007-01-23T14:52:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgundlach](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@pgundlach](https://www.ruby-forum.com/u/pgundlach)\
**Post date:** [January 23, 2007, 2:52pm UTC](https://www.ruby-forum.com/t/tar2rubyscript-getting-the-path-of-the-original-executable/83068/1 "2007-01-23T14:52:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pgundlach](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@pgundlach](https://www.ruby-forum.com/u/pgundlach)\
**Post date:** [January 23, 2007, 6:03pm UTC](https://www.ruby-forum.com/t/tar2rubyscript-getting-the-path-of-the-original-executable/83068/2 "2007-01-23T18:03:20Z")

</div>

* * *

$ 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”

---

<div class="post-metadata">

**Author:** ![pgundlach](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@pgundlach](https://www.ruby-forum.com/u/pgundlach)\
**Post date:** [January 23, 2007, 6:16pm UTC](https://www.ruby-forum.com/t/tar2rubyscript-getting-the-path-of-the-original-executable/83068/3 "2007-01-23T18:16:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pgundlach](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@pgundlach](https://www.ruby-forum.com/u/pgundlach)\
**Post date:** [January 26, 2007, 10:29am UTC](https://www.ruby-forum.com/t/tar2rubyscript-getting-the-path-of-the-original-executable/83068/4 "2007-01-26T10:29:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pgundlach](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b9e5f3/32.png) [@pgundlach](https://www.ruby-forum.com/u/pgundlach)\
**Post date:** [January 23, 2007, 6:55pm UTC](https://www.ruby-forum.com/t/tar2rubyscript-getting-the-path-of-the-original-executable/83068/5 "2007-01-23T18:55:34Z")

</div>

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/](http://www.erikveen.dds.nl/)
