Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,295 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,216 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



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

 
Reply to this topicStart new topic

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

ireland100
post 18 Jun, 2007 - 09:32 AM
Post #1


New D.I.C Head

*
Joined: 18 Jun, 2007
Posts: 2


My Contributions


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
User is offlineProfile CardPM

Go to the top of the page


rahulbatra
post 18 Jun, 2007 - 11:45 PM
Post #2


D.I.C Head

Group Icon
Joined: 28 Dec, 2005
Posts: 156



Dream Kudos: 275
My Contributions


A good idea is to execute
CODE
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,
CODE
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.
User is offlineProfile CardPM

Go to the top of the page

ireland100
post 19 Jun, 2007 - 01:50 AM
Post #3


New D.I.C Head

*
Joined: 18 Jun, 2007
Posts: 2


My Contributions


Thanks for that rahulbatra
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/6/08 09:31AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month