From: 7stud -- Date: 2008-03-04T18:34:48+09:00 Subject: Re: How do I get the server name? laredotornado wrote: > > > Thanks all for your replies but there's something odd. I guess I'm > still confused about how to access values from this thing that is not > quite a hash. In irb, I did as Andrei suggested and thought I saw a > HOSTNAME key, but when I try and print out the value ("puts > ENV['HOSTNAME']"), I get nil. Why does it appear when I print out the > hash but not when I try and access the value individually? > > Here's the irb action: > > irb(main):068:0* ENV.each { |key, value| puts "#{key} - #{value}" } > USER - myusername > LOGNAME - myusername > HOME - /home/myusername > PATH - /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/myusername/ > bin > MAIL - /var/spool/mail/myusername > SHELL - /bin/zsh > SSH_CLIENT - 67.190.94.163 61497 22 > SSH_CONNECTION - 67.190.94.163 61497 192.168.1.99 22 > SSH_TTY - /dev/pts/1 > TERM - xterm > SHLVL - 1 > PWD - /usr/local/apache2/htdocs/easyrx/app/controllers > OLDPWD - /usr/local/apache2/htdocs/easyrx/app > HOSTNAME - mydomain.com > HISTSIZE - 1000 > INPUTRC - /etc/inputrc > LS_COLORS - > Why did you think leaving out the: puts ENV['HOSTNAME'] as the next statement would help prove your point? -- Posted via http://www.ruby-forum.com/.