Determining system information

J

John Maclean

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}
 
J

John Maclean

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']}"
 
D

Daniel Berger

John said:
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}

require "rbconfig"
include Config

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

Regards,

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top