Test for OS name from inside ruby script

How do I test in my scripts for the OS type? So I can conditionally run
different code…?

thanks

On Sat, Jan 23, 2010 at 1:56 AM, Dale A. [email protected]
wrote:

How do I test in my scripts for the OS type? So I can conditionally run
different code…?

A quick google search led to this:
http://snippets.dzone.com/posts/show/6238 I imagine using RUBY_PLATFORM
in
some manner is a good solution.

On 23.01.2010 07:56, Dale A. wrote:

How do I test in my scripts for the OS type? So I can conditionally run
different code…?

It’s easiest with github.com/rdp/os

Jacob M. wrote:

On Sat, Jan 23, 2010 at 1:56 AM, Dale A. [email protected]
wrote:

How do I test in my scripts for the OS type? So I can conditionally run
different code…?

A quick google search led to this:
http://snippets.dzone.com/posts/show/6238 I imagine using RUBY_PLATFORM
in
some manner is a good solution.

Thanks I got it going. I am using ‘rbconfig’

On Jan 23, 12:09 am, Jacob M. [email protected]
wrote:

On Sat, Jan 23, 2010 at 1:56 AM, Dale A. [email protected] wrote:

How do I test in my scripts for the OS type? So I can conditionally run
different code…?

A quick google search led to this:http://snippets.dzone.com/posts/show/6238 I imagine using RUBY_PLATFORM in
some manner is a good solution.

No, do not use RUBY_PLATFORM. JRuby will return “java”, for example:

If you want something built in use rbconfig.rb. Specifically,
Config::CONFIG[‘host_os’]. Or you can use a 3rd party gem like sys-
uname or os.

Regards,

Dan

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs