# Discovering the OS

**URL:** <https://rubytalk.org/t/discovering-the-os/31234>\
**Category:** ruby-talk\
**Created:** [22 September 2006 16:35 UTC](https://rubytalk.org/t/discovering-the-os/31234 "2006-09-22T16:35:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Collier](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@David\_Collier](https://rubytalk.org/u/David_Collier)\
**Post date:** [22 September 2006 16:35 UTC](https://rubytalk.org/t/discovering-the-os/31234/1 "2006-09-22T16:35:26Z")

</div>

hi list -

just wondering if there is a way to find out which OS ruby is running on?

for these type of:

if (windows)  
&nbsp;&nbsp;system "start file.html"  
else if (mac)  
&nbsp;&nbsp;system "open file.html"  
end

> **···**
>
> --  
> -------------------------------------------  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;David "DC" Collier  
> [mailto:dc@pikkle.com](mailto:dc@pikkle.com)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+81 (0)80 6521 9559  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;skype: callto://d3ntaku  
> -------------------------------------------  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pikkle 株式会社  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[http://www.pikkle.com](http://www.pikkle.com)  
> -------------------------------------------

---

<div class="post-metadata">

**Author:** ![William\_Crawford](https://avatars.discourse-cdn.com/v4/letter/w/dbc845/32.png) [@William\_Crawford](https://rubytalk.org/u/William_Crawford)\
**Post date:** [22 September 2006 16:56 UTC](https://rubytalk.org/t/discovering-the-os/31234/2 "2006-09-22T16:56:43Z")

</div>

dc wrote:

> if (windows)  
> &nbsp;&nbsp;system "start file.html"  
> else if (mac)  
> &nbsp;&nbsp;system "open file.html"

&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;puts "Oy, nevermind! You can open it yourself!"

> end

hehe

Found this on Google.  
[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/47795](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/47795)

It looks like Config::CONFIG["arch"] is what you need to be looking at.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Ara.T.Howard6](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@Ara.T.Howard6](https://rubytalk.org/u/Ara.T.Howard6)\
**Post date:** [22 September 2006 16:57 UTC](https://rubytalk.org/t/discovering-the-os/31234/3 "2006-09-22T16:57:43Z")

</div>

try this

&nbsp;&nbsp;&nbsp;ruby -r rbconfig -r yaml -e' y Config::CONFIG '

-a

> **···**
>
> On Sat, 23 Sep 2006, dc wrote:
> 
> > hi list -
> > 
> > just wondering if there is a way to find out which OS ruby is running on?
> > 
> > for these type of:
> > 
> > if (windows)  
> > system "start file.html"  
> > else if (mac)  
> > system "open file.html"  
> > end
> 
> --  
> in order to be effective truth must penetrate like an arrow - and that is  
> likely to hurt. -- wei wu wei

---

<div class="post-metadata">

**Author:** ![David\_Roberts](https://avatars.discourse-cdn.com/v4/letter/d/c5a1d2/32.png) [@David\_Roberts](https://rubytalk.org/u/David_Roberts)\
**Post date:** [22 September 2006 17:02 UTC](https://rubytalk.org/t/discovering-the-os/31234/4 "2006-09-22T17:02:23Z")

</div>

dc wrote:

> hi list -
> 
> just wondering if there is a way to find out which OS ruby is running  
> on?
> 
> for these type of:
> 
> if (windows)  
> &nbsp;&nbsp;system "start file.html"  
> else if (mac)  
> &nbsp;&nbsp;system "open file.html"  
> end
> 
> --  
> -------------------------------------------  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;David "DC" Collier  
> [mailto:dc@pikkle](mailto:dc@pikkle).com  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+81 (0)80 6521 9559  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;skype: callto://d3ntaku

RUBY\_PLATFORM?

RUBY\_PLATFORM  
The identifier of the platform running this program. This string  
is in the same form as the platform identifier used by the GNU  
configure utility (which is not a coincidence).

David

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![William\_Crawford](https://avatars.discourse-cdn.com/v4/letter/w/dbc845/32.png) [@William\_Crawford](https://rubytalk.org/u/William_Crawford)\
**Post date:** [22 September 2006 17:10 UTC](https://rubytalk.org/t/discovering-the-os/31234/5 "2006-09-22T17:10:47Z")

</div>

David Roberts wrote:

> RUBY\_PLATFORM  
> The identifier of the platform running this program. This string  
> is in the same form as the platform identifier used by the GNU  
> configure utility (which is not a coincidence).

Spoilsport. Why's Ruby always gotta make things easy? -sigh-

Truly, that's the hardest thing for me to get used to... I'm used to  
having to work to find out things like that.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Kalman\_Noel](https://avatars.discourse-cdn.com/v4/letter/k/ad7895/32.png) [@Kalman\_Noel](https://rubytalk.org/u/Kalman_Noel)\
**Post date:** [22 September 2006 17:15 UTC](https://rubytalk.org/t/discovering-the-os/31234/6 "2006-09-22T17:15:10Z")

</div>

William Crawford schrieb:

> dc wrote:
> 
> > if (windows)
> 
> It looks like Config::CONFIG["arch"] is what you need to be looking at.

Hm, what about Config::CONFIG['target\_os'] or Config::CONFIG['host\_os']?

Kalman
