How to get operating system type info

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

···

--
Posted via http://www.ruby-forum.com/.

Dao Shi wrote:

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

Dao Shi wrote:

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.

puts RUBY_PLATFORM

···

--
Paul Lutus
http://www.arachnoid.com

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....

···

--
Posted via http://www.ruby-forum.com/.

Yes, should be /mswin/.

Please file a bug:

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

···

On Dec 3, 2006, at 12:00 , Dao Shi wrote:

Thanks Ken and Paul!

This is exactly what I need.

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

tua.ch - und andere Domains günstig und einfach online kaufen auf top-domains.ch

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/

--
Eric Hodel - drbrain@segment7.net - http://blog.segment7.net

I LIT YOUR GEM ON FIRE!