From: Zachary Scott Date: 2008-04-26T09:45:46+09:00 Subject: Re: determing what os is running ------=_Part_7098_3847408.1209170744399 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline import os.. wait nvm >.< On Fri, Apr 25, 2008 at 1:53 PM, Daniel Berger wrote: > > > On Apr 25, 10:59 am, Kyle Hunter wrote: > > cb wrote: > > > I need to execute commands differently based on the underlying > > > platform. I don't need it down to the patch level or anything like > > > that -- just basic stuff. > > > > > How do I test whether I'm runnnig on Windows, Linux, or Mac? > > > > > Thanks in advance. > > > > > CB > > > > if RUBY_PLATFORM =~ /linux/ then > > #Linux Stuff > > elsif RUBY_PLATFORM =~ /mswin32/ then > > #Windows Stuff > > end > > With other Ruby implementations out there this is no longer wise > because Sun and Microsoft have hija^H^H^H^H co-opted the term > 'platform'. If you check RUBY_PLATFORM with JRuby, for example, you'll > get 'java'. > > If you need to check the underlying OS, use rbconfig. > > require 'rbconfig' > include Config > > case CONFIG['host_os'] > when /mswin|windows/i > # Windows > when /linux/i > # Linux > when /sunos|solaris/i > # Solaris > else > # Whatever > end > > There's also the sys-uname library if you need more detailed > information. > > Regards, > > Dan > > ------=_Part_7098_3847408.1209170744399--