[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

locate oci8.rb

Rémi Lavergne

11/7/2007 5:41:00 PM

Hello,

I need to be able to dynamically locate the file oci8.rb from a sh
script...
Do you have any idea how to do this ?

Many Thanks,

R.
--
Posted via http://www.ruby-....

4 Answers

Robert Klemme

11/8/2007 7:02:00 AM

0

On 07.11.2007 18:40, Rémi Lavergne wrote:
> I need to be able to dynamically locate the file oci8.rb from a sh
> script...
> Do you have any idea how to do this ?

find / -type f -name oci8.rb

robert

Rémi Lavergne

11/8/2007 10:11:00 AM

0

Robert Klemme wrote:
> On 07.11.2007 18:40, R�mi Lavergne wrote:
>> I need to be able to dynamically locate the file oci8.rb from a sh
>> script...
>> Do you have any idea how to do this ?
>
> find / -type f -name oci8.rb
>
> robert


Hum... My question was not precise enough. I am looking for the location
of the particular oci8.rb file that my current ruby interpreter is
using. As it has to be done at each execution of my program, I would
like to avoid scanning the entire file system. My ruby interpreter is
able to locate it, I would like to be able to do the same either in ruby
or in sh script. Any idea ?

Thanks,

R.
--
Posted via http://www.ruby-....

Sylvain Joyeux

11/8/2007 10:42:00 AM

0

On Thu, Nov 08, 2007 at 07:11:28PM +0900, Rémi Lavergne wrote:
> My ruby interpreter is
> able to locate it, I would like to be able to do the same either in ruby
> or in sh script. Any idea ?
The interpreter searches the file in directories defined in $LOAD_PATH.
You can do the same ...

location = $LOAD_PATH.find { |dirname| File.exists?(File.join(dirname, filename) }

Sylvain


Rémi Lavergne

11/8/2007 10:49:00 AM

0

Robert Klemme wrote:
>
> puts $:.find {|dir| File.file? dir + "/oci8.rb"}
>


YES !
Works fine, thanks !
--
Posted via http://www.ruby-....