Get system name

V

Victor H. Goff III

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

Check out the Ruby Constants... PLATFORM could be one.
 
T

The Higgs bozo

Victor said:
Check out the Ruby Constants... PLATFORM could be one.

The constant is RUBY_PLATFORM.

If more info is needed, check the output of this,

require 'rbconfig'
require 'pp'
pp Config::CONFIG
 
N

Nedry

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

That's a great alias! I wish I'd thought of it.
Now someone unsubscribe me from this list, dammit. I can't figure out how,
cause I'm a moron!

(Just kidding, don't really unsub me...)

Angels and ministers of grace defend us!

- Hamlet, Act I, Scene 4
 
T

The Higgs bozo

Kless said:
I haven't that constant, but 'target_os'.

RUBY_PLATFORM is a top-level constant, apart from Config::CONFIG.

$ ruby -e 'p RUBY_PLATFORM'
 
D

Daniel Berger

The constant is RUBY_PLATFORM.

I recommend against this because of JRuby (and probably IronRuby).
JRuby, for example, will return "java" for RUBY_PLATFORM.
If more info is needed, check the output of this,

require 'rbconfig'
require 'pp'
pp Config::CONFIG

There you go. Take a look at Config['host_os'].

Regards,

Dan
 
T

The Higgs bozo

Daniel said:
The constant is RUBY_PLATFORM.

I recommend against this because of JRuby (and probably IronRuby).
JRuby, for example, will return "java" for RUBY_PLATFORM.
If more info is needed, check the output of this,

require 'rbconfig'
require 'pp'
pp Config::CONFIG

There you go. Take a look at Config['host_os'].

I wonder if RUBY_PLATFORM should be deprecated, then?

I've used 'target_os' in the past, a decision I rationalized thusly: on
the off chance that ruby spits out an executable of any form, I want the
platform of that executable. In hindsight I wonder if it makes any
sense.

Is there an example of CONFIG["target_os"] != CONFIG["host_os"] ?
 
K

Kless

Is there an example of CONFIG["target_os"] != CONFIG["host_os"] ?
Yes, my Ubuntu shows:

$ ruby -e 'require "rbconfig"; p Config::CONFIG["host_os"],
Config::CONFIG["target_os"]'

"linux-gnu"
"linux"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,197
Messages
2,571,040
Members
47,642
Latest member
arunkumar99

Latest Threads

Top