[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Determining system information

John Maclean

2/11/2006 5:20:00 PM

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 Maclean
MSc (DIC)
07739 171 531



3 Answers

Tim Hunter

2/11/2006 5:24:00 PM

0

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

John Maclean

2/11/2006 7:15:00 PM

0

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
<info@jayeola.org> 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}
>


--
John Maclean
MSc (DIC)
07739 171 531



Daniel Berger

2/11/2006 7:57:00 PM

0

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}
>
> --
> John Maclean
> MSc (DIC)
> 07739 171 531

require "rbconfig"
include Config

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

Regards,

Dan