[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

figuring out what platform i'm on

aslak hellesoy

12/2/2004 3:44:00 PM

Can anyone tell me how I can figure out from Ruby what platform I'm
running on? My Ruby program needs to know whether it's running on
linux, cygwin, windows etc...

Aslak


5 Answers

Austin Ziegler

12/2/2004 3:57:00 PM

0

On Fri, 3 Dec 2004 00:44:28 +0900, aslak hellesoy
<aslak.hellesoy@gmail.com> wrote:
> Can anyone tell me how I can figure out from Ruby what platform I'm
> running on? My Ruby program needs to know whether it's running on
> linux, cygwin, windows etc...

RUBY_PLATFORM

It's not perfect, but it's a good guess.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca


Florian Gross

12/2/2004 4:06:00 PM

0

aslak hellesoy wrote:

> Can anyone tell me how I can figure out from Ruby what platform I'm
> running on? My Ruby program needs to know whether it's running on
> linux, cygwin, windows etc...

Use RUBY_PLATFORM or rbconfig.rb

Kent Sibilev

12/2/2004 4:13:00 PM

0

$ irb
irb(main):001:0> RUBY_PLATFORM
=> "powerpc-darwin7.6.0"
irb(main):002:0>

Cheers,
Kent.
On Dec 2, 2004, at 10:44 AM, aslak hellesoy wrote:

> Can anyone tell me how I can figure out from Ruby what platform I'm
> running on? My Ruby program needs to know whether it's running on
> linux, cygwin, windows etc...
>
> Aslak
>



djberg96

12/2/2004 6:53:00 PM

0

Austin Ziegler <halostatue@gmail.com> wrote in message news:<9e7db91104120207572417ae4f@mail.gmail.com>...
> On Fri, 3 Dec 2004 00:44:28 +0900, aslak hellesoy
> <aslak.hellesoy@gmail.com> wrote:
> > Can anyone tell me how I can figure out from Ruby what platform I'm
> > running on? My Ruby program needs to know whether it's running on
> > linux, cygwin, windows etc...
>
> RUBY_PLATFORM
>
> It's not perfect, but it's a good guess.
>
> -austin

For more detailed information, there is sys-uname. Available on the
RAA. Yes, it works on Windows, too. :)

Regards,

Dan

Jamis Buck

12/2/2004 7:20:00 PM

0

Daniel Berger wrote:
> Austin Ziegler <halostatue@gmail.com> wrote in message news:<9e7db91104120207572417ae4f@mail.gmail.com>...
>
>>On Fri, 3 Dec 2004 00:44:28 +0900, aslak hellesoy
>><aslak.hellesoy@gmail.com> wrote:
>>
>>>Can anyone tell me how I can figure out from Ruby what platform I'm
>>>running on? My Ruby program needs to know whether it's running on
>>>linux, cygwin, windows etc...
>>
>>RUBY_PLATFORM
>>
>>It's not perfect, but it's a good guess.
>>
>>-austin
>
>
> For more detailed information, there is sys-uname. Available on the
> RAA. Yes, it works on Windows, too. :)
>
> Regards,
>
> Dan

And there's always the quick-and-dirty approach that has been mentioned
before, to differentiate between windows and everything else:

if File::ALT_SEPARATOR
puts "I'm on windows!"
else
puts "I'm not on windows!"
end

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck...