# Discovering the OS

**URL:** <https://www.ruby-forum.com/t/discovering-the-os/69656>\
**Category:** Ruby\
**Created:** [September 22, 2006, 6:35pm UTC](https://www.ruby-forum.com/t/discovering-the-os/69656 "2006-09-22T18:35:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 22, 2006, 6:35pm UTC](https://www.ruby-forum.com/t/discovering-the-os/69656/1 "2006-09-22T18:35:53Z")

</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)  
system “start file.html”  
else if (mac)  
system “open file.html”  
end

## –

```
  David "DC" Collier

```

[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
+81 (0)80 6521 9559  
skype: callto://d3ntaku

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 22, 2006, 6:56pm UTC](https://www.ruby-forum.com/t/discovering-the-os/69656/2 "2006-09-22T18:56:40Z")

</div>

dc wrote:

> if (windows)  
> system “start file.html”  
> else if (mac)  
> system “open file.html”  
> else  
> 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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 22, 2006, 6:59pm UTC](https://www.ruby-forum.com/t/discovering-the-os/69656/3 "2006-09-22T18:59:56Z")

</div>

On Sat, 23 Sep 2006, dc wrote:

> end  
> try this

ruby -r rbconfig -r yaml -e’ y Config::CONFIG ’

-a

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 22, 2006, 7:02pm UTC](https://www.ruby-forum.com/t/discovering-the-os/69656/4 "2006-09-22T19:02:20Z")

</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)  
> system “start file.html”  
> else if (mac)  
> system “open file.html”  
> end
> 
> ## –
> 
> ```
> David "DC" Collier
> 
> ```
> 
> [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> +81 (0)80 6521 9559  
> 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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 22, 2006, 7:15pm UTC](https://www.ruby-forum.com/t/discovering-the-os/69656/5 "2006-09-22T19:15:58Z")

</div>

William C. 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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 22, 2006, 7:10pm UTC](https://www.ruby-forum.com/t/discovering-the-os/69656/6 "2006-09-22T19:10:44Z")

</div>

David R. 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.
