In Ruby script, I want to get OS information, not only Linux, but also 32bit or 64bit.
That's because my program will run on multiple Linux platform. It calls a third part tool, the tool has sub-folder: lin32
, lin64
, I need to call proper version based on OS info.
In Ruby you can use RUBY_PLATFORM
constant. This constant produces a base name of your OS and kernel bits level.
E.g. in irb:
1.9.3-p392 :001 > RUBY_PLATFORM
=> "x86_64-linux" - Linux based OS with 64-bit
=> "i686-linux" - Linux based OS with 32-bit
Also, you can try someth like:
ver = `getconf LONG_BIT`
or
ver = `arch`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With