Test for OS name from inside ruby script

Discussion in 'Ruby' started by Dale Ackerman, Jan 23, 2010.

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

    thanks
    --
    Posted via http://www.ruby-forum.com/.
     
    Dale Ackerman, Jan 23, 2010
    #1
    1. Advertising

  2. On 23.01.2010 07:56, Dale Ackerman 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

    --
    Phillip Gawlowski
     
    Phillip Gawlowski, Jan 23, 2010
    #2
    1. Advertising

  3. [Note: parts of this message were removed to make it a legal post.]

    On Sat, Jan 23, 2010 at 1:56 AM, Dale Ackerman <> 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.
     
    Jacob Mitchell, Jan 23, 2010
    #3
  4. Jacob Mitchell wrote:
    > On Sat, Jan 23, 2010 at 1:56 AM, Dale Ackerman <>
    > 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'

    --
    Posted via http://www.ruby-forum.com/.
     
    Dale Ackerman, Jan 24, 2010
    #4
  5. On Jan 23, 12:09=A0am, Jacob Mitchell <>
    wrote:
    > On Sat, Jan 23, 2010 at 1:56 AM, Dale Ackerman <> wrote=

    :
    > > How do I test in my scripts for the OS type? =A0So I can conditionally =

    run
    > > different code..?

    >
    > A quick google search led to this:http://snippets.dzone.com/posts/show/62=

    38=A0I 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
     
    Daniel Berger, Jan 24, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William D. Sossamon
    Replies:
    0
    Views:
    411
    William D. Sossamon
    May 4, 2004
  2. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    713
    Skybuck Flying
    Oct 4, 2009
  3. William D. Sossamon
    Replies:
    0
    Views:
    177
    William D. Sossamon
    May 4, 2004
  4. Saravanan Sundaramoorthy

    how to test a ruby script from another ruby script?

    Saravanan Sundaramoorthy, Jul 17, 2010, in forum: Ruby
    Replies:
    1
    Views:
    147
    Roger Pack
    Jul 19, 2010
  5. J M
    Replies:
    2
    Views:
    115
    Tad McClellan
    Nov 6, 2004
Loading...

Share This Page