[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby Scripts Location

Doug Bromley

7/10/2006 3:54:00 PM

Hi All

I know this should be very simple but I can't for the life of me find
the answer using Pickaxe or Google.

I want to be able to access the location/path of the currently
executing Ruby script. I thought it was a global variable "$" but
looking at the lists I've seen I can't find it.

Your help would be much appreciated.

Thanks.

Doug

2 Answers

Joel VanderWerf

7/10/2006 3:57:00 PM

0

Doug Bromley wrote:
> I want to be able to access the location/path of the currently
> executing Ruby script. I thought it was a global variable "$" but
> looking at the lists I've seen I can't find it.

$0 is probably what you want. Use File.expand_path on it to get the full
path.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Gennady Bystritsky

7/10/2006 3:58:00 PM

0

$0, or __FILE__ in the main script file.

Gennady.

> -----Original Message-----
> From: Doug Bromley [mailto:doug.bromley@gmail.com]
> Sent: Monday, July 10, 2006 8:54 AM
> To: ruby-talk ML
> Subject: Ruby Scripts Location
>
> Hi All
>
> I know this should be very simple but I can't for the life of me find
> the answer using Pickaxe or Google.
>
> I want to be able to access the location/path of the currently
> executing Ruby script. I thought it was a global variable "$" but
> looking at the lists I've seen I can't find it.
>
> Your help would be much appreciated.
>
> Thanks.
>
> Doug
>
>