find executables on windows

A

Ara.T.Howard

in linux i'd do something (un-tested) like:

def find_bin bin
bin = nil
path = ENV['PATH'].split File::pATH_SEPARATOR
path.each do |dir|
b = File::join dir, bin
return b if File::executable? b
end
bin
end

what would the equivalient be in windows? should the above work or do i need
to check some other env vars?

cheers.

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
D

Dave Burt

Ara.T.Howard asked...
in linux i'd do something (un-tested) like:

def find_bin bin
bin = nil
path = ENV['PATH'].split File::pATH_SEPARATOR
path.each do |dir|
b = File::join dir, bin
return b if File::executable? b
end
bin
end

what would the equivalient be in windows? should the above work or do i
need
to check some other env vars?

That's the only env var. There's no executable flag, though, and I don't
know what File::executable? does on Windows. I'd try exist? - and you'll
need to append the suffixes in ENV['PATHEXT']. (.com, .exe, .bat, .cmd,
maybe more like .js and .rb)

Cheers,
Dave
 
N

nobu.nokada

Hi,

At Tue, 13 Sep 2005 22:38:17 +0900,
Ara.T.Howard wrote in [ruby-talk:155922]:
what would the equivalient be in windows? should the above work or do i need
to check some other env vars?

See find_executable in lib/mkmf.rb.
 
A

Ara.T.Howard

Hi,

At Tue, 13 Sep 2005 22:38:17 +0900,
Ara.T.Howard wrote in [ruby-talk:155922]:
what would the equivalient be in windows? should the above work or do i need
to check some other env vars?

See find_executable in lib/mkmf.rb.


10 minutes to wait for an answer and it's already written - i don't know what
i'm paying for! ;-)

cheers.

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top