Forum: Ruby Determining system information

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
508861510639b56d61eb30e6a28b01d9?d=identicon&s=25 John Maclean (Guest)
on 2006-02-11 18:20
(Received via mailing list)
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}
37a3c73ffbf864e4b28f7f2384ee12ce?d=identicon&s=25 Timothy Hunter (tim-hunter)
on 2006-02-11 18:28
(Received via mailing list)
John Maclean 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
508861510639b56d61eb30e6a28b01d9?d=identicon&s=25 John Maclean (Guest)
on 2006-02-11 20:15
(Received via mailing list)
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 Maclean
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (Guest)
on 2006-02-11 20:58
(Received via mailing list)
John Maclean wrote:
> John Maclean
> MSc (DIC)
> 07739 171 531

require "rbconfig"
include Config

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

Regards,

Dan
This topic is locked and can not be replied to.