2 Replies - 13685 Views - Last Post: 19 June 2007 - 01:50 AM Rate Topic: -----

#1 ireland100  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-June 07

How to find out the OS that your ruby script is currently running on

Post icon  Posted 18 June 2007 - 09:32 AM

Can somebody please tell me what is the code to find out the OS that your ruby script is running on.
This script will be running on Windows OS only
Is This A Good Question/Topic? 0
  • +

#5 rahulbatra  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 183
  • Joined: 28-December 05

Re: How to find out the OS that your ruby script is currently running on

Posted 18 June 2007 - 11:45 PM

A good idea is to execute
puts ENV['OS']

For Windows systems, the output would be Windows_NT.

However this will return you an empty string for Linux. For further probing, you can use the following line,
puts RUBY_PLATFORM

which will give you the output i386-mswin32 for x86 Windows machines. Linux systems will output "linux" instead of "mswin32" in this case.
Was This Post Helpful? 1

#6 ireland100  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-June 07

Re: How to find out the OS that your ruby script is currently running on

Posted 19 June 2007 - 01:50 AM

Thanks for that rahulbatra
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1