Determining system information

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}

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

John M. wrote:

John M.
MSc (DIC)
07739 171 531

require “rbconfig”
include Config

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

Regards,

Dan

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.