Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Test for OS name from inside ruby script

Reply
Thread Tools

Test for OS name from inside ruby script

 
 
Dale Ackerman
Guest
Posts: n/a
 
      01-23-2010
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/.

 
Reply With Quote
 
 
 
 
Phillip Gawlowski
Guest
Posts: n/a
 
      01-23-2010
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


 
Reply With Quote
 
 
 
 
Jacob Mitchell
Guest
Posts: n/a
 
      01-23-2010
[Note: parts of this message were removed to make it a legal post.]

On Sat, Jan 23, 2010 at 1:56 AM, Dale Ackerman <(E-Mail Removed)> 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.

 
Reply With Quote
 
Dale Ackerman
Guest
Posts: n/a
 
      01-24-2010
Jacob Mitchell wrote:
> On Sat, Jan 23, 2010 at 1:56 AM, Dale Ackerman <(E-Mail Removed)>
> 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/.

 
Reply With Quote
 
Daniel Berger
Guest
Posts: n/a
 
      01-24-2010
On Jan 23, 12:09=A0am, Jacob Mitchell <(E-Mail Removed)>
wrote:
> On Sat, Jan 23, 2010 at 1:56 AM, Dale Ackerman <(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to test a ruby script from another ruby script? Saravanan Sundaramoorthy Ruby 1 07-19-2010 12:06 PM
Pass variables to arbitrary ruby script: ruby script.rb Mario Gr Ruby 3 07-04-2009 06:00 AM
"ruby script.rb" versus "xterm -e ruby script.rb" Sy Ruby 0 04-16-2005 12:08 AM
pulling or getting perl script name inside script J M Perl Misc 2 11-06-2004 03:16 AM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments