# eRuby giving problems with http.rb

**URL:** <https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917>\
**Category:** Ruby\
**Created:** [February 2, 2008, 4:30pm UTC](https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917 "2008-02-02T16:30:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![adityanag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@adityanag](https://www.ruby-forum.com/u/adityanag)\
**Post date:** [February 2, 2008, 4:30pm UTC](https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917/1 "2008-02-02T16:30:53Z")

</div>

Hi,  
I have downloaded a piece of code in ruby that will get quotes from  
Yahoo Finance. The code is pasted below:

require ‘yahoofinance’  
require ‘open-uri’  
require ‘rexml/document’  
require ‘pp’  
require ‘net/http.rb’

# Set the type of quote we want to retrieve.

# Available type are:

# - YahooFinanace::StandardQuote

# - YahooFinanace::ExtendedQuote

# - YahooFinanace::RealTimeQuote

quote\_type = YahooFinance::StandardQuote

# Set the symbols for which we want to retrieve quotes.

# You can include more than one symbol by separating

# them with a ‘,’ (comma).

quote\_symbols = “500570.BO”  
#quote\_symbols = “YHOO”

# Get the quotes from Yahoo! Finance. The get\_quotes method call

# returns a Hash containing one quote object of type “quote\_type” for

# each symbol in “quote\_symbols”. If a block is given, it will be

# called with the quote object (as in the example below).

YahooFinance::get\_quotes( quote\_type, quote\_symbols ) do |qt|  
puts “QUOTING: #{qt.symbol}”  
puts qt.to\_s  
end

# You can get the same effect using the quote specific method.

quotes = YahooFinance::get\_standard\_quotes( quote\_symbols )  
quotes.each do |symbol, qt|  
puts “QUOTING: #{symbol}”  
puts qt.to\_s  
end

The above piece of code works fine when i use this directly in a .rb  
file like this:  
ruby testyahoo.rb  
I get the stock quotes correctly.

But i have problems if i put exactly the same code between html tags  
call it this way:  
eruby testyahoo.rhtml  
Code for testyahoo.rhtml file is pasted below:

#!C:/appdev/ruby/bin/eruby.exe

eruby test
# eruby test

\<%  
require ‘yahoofinance’  
require ‘open-uri’  
require ‘rexml/document’  
require ‘pp’  
require ‘net/http.rb’

# Set the type of quote we want to retrieve.

# Available type are:

# - YahooFinanace::StandardQuote

# - YahooFinanace::ExtendedQuote

# - YahooFinanace::RealTimeQuote

quote\_type = YahooFinance::StandardQuote

# Set the symbols for which we want to retrieve quotes.

# You can include more than one symbol by separating

# them with a ‘,’ (comma).

quote\_symbols = “500570.BO”  
#quote\_symbols = “YHOO”

# Get the quotes from Yahoo! Finance. The get\_quotes method call

# returns a Hash containing one quote object of type “quote\_type” for

# each symbol in “quote\_symbols”. If a block is given, it will be

# called with the quote object (as in the example below).

YahooFinance::get\_quotes( quote\_type, quote\_symbols ) do |qt|  
puts “QUOTING: #{qt.symbol}”  
puts qt.to\_s  
end

# You can get the same effect using the quote specific method.

quotes = YahooFinance::get\_standard\_quotes( quote\_symbols )  
quotes.each do |symbol, qt|  
puts “QUOTING: #{symbol}”  
puts qt.to\_s  
end

%\>

I have attached a screen capture of the errors when the .rhtml file is  
executed.  
I am not able to figure out if my eruby installation is wrong or if my  
path settings are incorrect. I tried eruby with other pieces of code  
that dont need http.rb and these pieces of code work absolutely fine.

I have ruby, rubygems, eruby, mysql and apache running on a windows  
vista system.

Any inputs would help.

Thanks & Regards  
Aditya

---

<div class="post-metadata">

**Author:** ![adityanag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@adityanag](https://www.ruby-forum.com/u/adityanag)\
**Post date:** [February 2, 2008, 5:23pm UTC](https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917/2 "2008-02-02T17:23:58Z")

</div>

On Feb 2, 2008 4:30 PM, Adi N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have attached a screen capture of the errors when the .rhtml file is  
> executed.  
> I am not able to figure out if my eruby installation is wrong or if my  
> path settings are incorrect. I tried eruby with other pieces of code  
> that dont need http.rb and these pieces of code work absolutely fine.

(Without reading your full post:) The error says dns doesn’t work.  
Either your connection is down, or you have wrong dns setting,  
or you have a typo somewhere, causing dns resoultion to fail.

Or, yahoo changed their host-naming scheme and the library doesn’t  
reflect that yet.

HTH,

Jano

---

<div class="post-metadata">

**Author:** ![adityanag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@adityanag](https://www.ruby-forum.com/u/adityanag)\
**Post date:** [February 2, 2008, 7:24pm UTC](https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917/3 "2008-02-02T19:24:34Z")

</div>

Jano S. wrote:

> On Feb 2, 2008 4:30 PM, Adi N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I have attached a screen capture of the errors when the .rhtml file is  
> > executed.  
> > I am not able to figure out if my eruby installation is wrong or if my  
> > path settings are incorrect. I tried eruby with other pieces of code  
> > that dont need http.rb and these pieces of code work absolutely fine.
> 
> (Without reading your full post:) The error says dns doesn’t work.  
> Either your connection is down, or you have wrong dns setting,  
> or you have a typo somewhere, causing dns resoultion to fail.
> 
> Or, yahoo changed their host-naming scheme and the library doesn’t  
> reflect that yet.
> 
> HTH,
> 
> Jano

Hi Ajno,  
Thanks for the reply.  
I just have a couple of questions here.  
You have given me a list of possible errors. Are any of these specific  
to eRuby? I do not have any problme with the same code executed as a .rb  
file through ruby but i have it only when i execute it as a .rhtml  
through eruby.

Thanks and Regards  
Aditya.

---

<div class="post-metadata">

**Author:** ![adityanag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@adityanag](https://www.ruby-forum.com/u/adityanag)\
**Post date:** [February 3, 2008, 7:37am UTC](https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917/4 "2008-02-03T07:37:05Z")

</div>

Jano S. wrote:

> On Feb 2, 2008 7:24 PM, Adi N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi Ajno,  
> > Thanks for the reply.  
> > I just have a couple of questions here.  
> > You have given me a list of possible errors. Are any of these specific  
> > to eRuby? I do not have any problme with the same code executed as a .rb  
> > file through ruby but i have it only when i execute it as a .rhtml  
> > through eruby.
> 
> Hi,
> 
> as I have written, I haven’t read your full post 😉 So, after your  
> questions, I guess there’s a problem with rights somewhere.  
> You may try to simplify your tests to a simple http request, although  
> it won’t help much (except it might be faster to check).
> 
> Vista’s rights are tighter than XP. Some hints what you can try:
> 
> 1. shutdown firewall if you have any
> 2. running apache under normal user if you run it as a service
> 3. run rhtml under webrick to see if it makes a difference
> 4. run your standalone script as a cgi. it won’t get any input, but  
> the error should be logged somewhere in the apache logs  
> (don’t forget proper shebang line)
> 5. examine apache and system logs (sorry if it’s too obvious)
> 
> I haven’t use eruby on windows, so these are just guesses.
> 
> Jano

Hi Jano,  
Thanks a lot for your time.

Just to put things in perspective…the eruby error springs up even when  
i run the script from the command prompt. Thats the reason i have  
stopped doubting apache now.  
So, i shall first check firewall settings and dns settings.  
Do you know of some website where i can find more info on this problem ?

Thanks & Regards  
Aditya.

---

<div class="post-metadata">

**Author:** ![adityanag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@adityanag](https://www.ruby-forum.com/u/adityanag)\
**Post date:** [February 2, 2008, 8:50pm UTC](https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917/5 "2008-02-02T20:50:05Z")

</div>

On Feb 2, 2008 7:24 PM, Adi N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi Ajno,  
> Thanks for the reply.  
> I just have a couple of questions here.  
> You have given me a list of possible errors. Are any of these specific  
> to eRuby? I do not have any problme with the same code executed as a .rb  
> file through ruby but i have it only when i execute it as a .rhtml  
> through eruby.

Hi,

as I have written, I haven’t read your full post 😉 So, after your  
questions, I guess there’s a problem with rights somewhere.  
You may try to simplify your tests to a simple http request, although  
it won’t help much (except it might be faster to check).

Vista’s rights are tighter than XP. Some hints what you can try:

1. shutdown firewall if you have any
2. running apache under normal user if you run it as a service
3. run rhtml under webrick to see if it makes a difference
4. run your standalone script as a cgi. it won’t get any input, but  
the error should be logged somewhere in the apache logs  
(don’t forget proper shebang line)
5. examine apache and system logs (sorry if it’s too obvious)

I haven’t use eruby on windows, so these are just guesses.

Jano

---

<div class="post-metadata">

**Author:** ![adityanag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@adityanag](https://www.ruby-forum.com/u/adityanag)\
**Post date:** [February 4, 2008, 1:47pm UTC](https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917/6 "2008-02-04T13:47:18Z")

</div>

> Hi Jano,  
> Thanks a lot for your time.
> 
> Just to put things in perspective…the eruby error springs up even when  
> i run the script from the command prompt. Thats the reason i have  
> stopped doubting apache now.  
> So, i shall first check firewall settings and dns settings.  
> Do you know of some website where i can find more info on this problem ?

In april, there was similar problem in the thread “eruby & Mechanize  
error” unfortunately without answer.  
I have tried your script under xp and it does not work either.

What worked for me: use erb or erubis instead of eruby. Erubis may be  
even faster, though I won’t tell  
you how to plug it into apache.

It seems that eruby’s build (eruby-1.0.5-i386-mswin32-1.8.zip) has  
compatibility problem with current ruby (1.8.6-p111)

---

<div class="post-metadata">

**Author:** ![adityanag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@adityanag](https://www.ruby-forum.com/u/adityanag)\
**Post date:** [February 5, 2008, 4:40am UTC](https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917/7 "2008-02-05T04:40:44Z")

</div>

Jano S. wrote:

> On Feb 4, 2008 1:46 PM, Jano S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > What worked for me: use erb or erubis instead of eruby.
> 
> Just a note:
> 
> erb - bundled in one-click  
> erubis - gem install erubis
> 
> use erb.cmd or erubis.cmd (or ruby.exe c:/ruby/bin/erubis  
> ) instead of eruby.exe

Hi Jano,  
Thanks a lot.  
Shall try the same and let you know the results.  
Compatibility issue is my guess as well since the same code ahs not  
hhhp.rb problems with ruby.exe but has problems with eruby.exe.

Regards  
Adi.

---

<div class="post-metadata">

**Author:** ![adityanag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/34f0e0/32.png) [@adityanag](https://www.ruby-forum.com/u/adityanag)\
**Post date:** [February 4, 2008, 1:52pm UTC](https://www.ruby-forum.com/t/eruby-giving-problems-with-http-rb/127917/8 "2008-02-04T13:52:04Z")

</div>

On Feb 4, 2008 1:46 PM, Jano S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What worked for me: use erb or erubis instead of eruby.

Just a note:

erb - bundled in one-click  
erubis - gem install erubis

use erb.cmd or erubis.cmd (or ruby.exe c:/ruby/bin/erubis  
) instead of eruby.exe
