How to get operating system type info

D

Dao Shi

Hi Guys,

I'm writing a software building script in Ruby for Unix and Windows.

I want to know the type of the platform that my script is running on -
whether it's Windows, Linux or MacOSX. I need to do something special
for different os.

Is there any way to get this without hacking by myself? Google gave me
nothing useful.

Thanks,
D
 
K

Ken Allen

Dao said:
Hi Guys,

I'm writing a software building script in Ruby for Unix and Windows.

I want to know the type of the platform that my script is running on -
whether it's Windows, Linux or MacOSX. I need to do something special
for different os.

Is there any way to get this without hacking by myself? Google gave me
nothing useful.

Thanks,
D
The RUBY_PLATFORM constant is what you want.

irb(main):001:0> RUBY_PLATFORM
=> "i386-mswin32"

Ken
 
D

Dao Shi

Thanks Ken and Paul!

This is exactly what I need.

BTW I think this might be helpful for others as well.

http://www.tua.ch/ruby/platform/platform.html

And is this a bug here?

rdoc/options.rb line 536 :

# Check that the right version of 'dot' is available.
# Unfortuately this doesn't work correctly under Windows NT,
# so we'll bypass the test under Windows

def check_diagram
return if RUBY_PLATFORM =~ /win/

darwin will match this too....
 
E

Eric Hodel

Thanks Ken and Paul!

This is exactly what I need.

BTW I think this might be helpful for others as well.

http://www.tua.ch/ruby/platform/platform.html

And is this a bug here?

rdoc/options.rb line 536 :

# Check that the right version of 'dot' is available.
# Unfortuately this doesn't work correctly under Windows NT,
# so we'll bypass the test under Windows

def check_diagram
return if RUBY_PLATFORM =~ /win/

Yes, should be /mswin/.

Please file a bug:

http://rubyforge.org/tracker/?func=add&group_id=627&atid=2472
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top