# Determining system information

**URL:** <https://www.ruby-forum.com/t/determining-system-information/53616>\
**Category:** Ruby\
**Created:** [February 11, 2006, 6:20pm UTC](https://www.ruby-forum.com/t/determining-system-information/53616 "2006-02-11T18:20:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [February 11, 2006, 6:20pm UTC](https://www.ruby-forum.com/t/determining-system-information/53616/1 "2006-02-11T18:20:21Z")

</div>

Chaps,

Running ENV in irb displays the system’s environment. I’ve tried the  
same thing in a script. What’s missing here?

#!/usr/bin/ruby -w  
stuff = %w{ENV RUBY\_VERSION RUBY\_RELEASE\_DATE RUBY\_PLATFORM VERSION}  
stuff.each{|foo| foo}

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [February 11, 2006, 6:28pm UTC](https://www.ruby-forum.com/t/determining-system-information/53616/2 "2006-02-11T18:28:37Z")

</div>

John M. wrote:

> Chaps,
> 
> Running ENV in irb displays the system’s environment. I’ve tried the  
> same thing in a script. What’s missing here?
> 
> #!/usr/bin/ruby -w  
> stuff = %w{ENV RUBY\_VERSION RUBY\_RELEASE\_DATE RUBY\_PLATFORM VERSION}  
> stuff.each{|foo| foo}

irb is helping you out a bit. In a script, try

puts ENV.inspect

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [February 11, 2006, 8:58pm UTC](https://www.ruby-forum.com/t/determining-system-information/53616/3 "2006-02-11T20:58:31Z")

</div>

John M. wrote:

> John M.  
> MSc (DIC)  
> 07739 171 531

require “rbconfig”  
include Config

CONFIG.sort.each{ |k,v| puts “#{k} =\> #{v}” }

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![jmaenpaa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de053/32.png) [@jmaenpaa](https://www.ruby-forum.com/u/jmaenpaa)\
**Post date:** [February 11, 2006, 8:15pm UTC](https://www.ruby-forum.com/t/determining-system-information/53616/4 "2006-02-11T20:15:29Z")

</div>

Thanks for that reply. In response to your tip I writen the  
following:-- (Note that the stuff below #== is only shown by irb and not  
when run in a shell)  
#!/usr/bin/ruby -w

puts “\e[2J\e[0;0H”  
puts "\*\*\*\* quick system check \*\*\*\* "  
puts “your user name is #{ENV[‘USER’]}”  
puts “your home dir is #{ENV[‘HOME’]}”  
puts “ssh environ is #{ENV[‘SSH\_AGENT\_PID’]}”  
puts “hostname is #{ENV[‘HOSTNAME’]}”  
puts “history size is #{ENV[‘HISTSIZE’]}”  
puts “path is #{ENV[‘PATH’]}”  
puts “your shell is #{ENV[‘SHELL’]}”  
puts “window manager is #{ENV[‘DESKTOP\_SESSION’]}”  
puts “current working dir is #{ENV[‘PWD’]}”  
puts “language environment is #{ENV[‘LANG’]}”  
puts  
puts  
require ‘rbconfig.rb’  
include Config  
CONFIG[“host”]  
CONFIG[“libdir”]

# ===================================================

puts “your terminals have #{ENV[‘LINES’]} lines and #{ENV[‘COLUMNS’]}  
columns” puts "#{ENV[‘LINES’]} #{ENV[‘COLUMNS’]} "  
puts “your ruby lib is #{ENV[‘RUBYLIB’]}”  
puts “config is #{ENV[‘CONFIG’]}”  
puts “your dln path is #{ENV[‘DLN\_LIBRARY\_PATH’]}”  
puts “your ruby shell is #{ENV[‘RUBYSHELL’]}”  
puts “your ruby options are #{ENV[‘RUBYOPT’]}”  
puts “path to ruby TCL shared library or DLL #{ENV[‘RUBY\_TCL\_DLL’]}”  
puts “your ruby path is #{ENV[‘RUBYPATH’]}”

On Sun, 12 Feb 2006 02:20:10 +0900 John M.
