# Program works in irb, but not in script

**URL:** <https://www.ruby-forum.com/t/program-works-in-irb-but-not-in-script/98847>\
**Category:** Ruby\
**Created:** [July 18, 2006, 4:55pm UTC](https://www.ruby-forum.com/t/program-works-in-irb-but-not-in-script/98847 "2006-07-18T16:55:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@johnf](https://www.ruby-forum.com/u/johnf)\
**Post date:** [July 18, 2006, 4:55pm UTC](https://www.ruby-forum.com/t/program-works-in-irb-but-not-in-script/98847/1 "2006-07-18T16:55:35Z")

</div>

Hey folks,

Apologies if this is a very extreme utterly really nubie question, but I  
am  
trying to learn Ruby and have run into a bit of a snag with a small  
program  
that attempts to define a method with four variables. The program fails  
with the following error message:

zoom.rb:4:in `open': Connect failed (10000) z3950.loc.gov (RuntimeError) :7090 from zoom.rb:4:in `zoomreturn’  
from zoom.rb:21

What’s weird is that if I go through irb and type in the entire method  
def  
and then supply it with four variables, the program works. So I’m  
pretty  
stymied.

The program is below. Note that the “zoom” stuff I’m referring to in  
here  
is a particular protocol that queries library catalogs. The ruby module  
for  
it is at [http://ruby-zoom.rubyforge.org](http://ruby-zoom.rubyforge.org)

If anyone wants to try it themselves to see, try using the following  
variables for server, dbname, syntax, isbn:

> **[Frequently Asked Questions - LCCN Permalink](https://lccn.loc.gov/)**
>
> Frequently Asked Questions: LCCN Permalink

Voyager  
USMARC  
0253333490

If it works correctly, the method should return a MARC record  
(basically, an  
electronic library card) about a book on dinosaurs.

Thanks for taking a look,

jf.

* * *

require ‘zoom’

def zoomreturn(server, dbname, syntax, isbn)  
ZOOM::Connection.open(server, 7090) do |conn|  
conn.database\_name = dbname  
conn.preferred\_record\_syntax = syntax  
rset = conn.search(isbn)  
p rset [0]  
end  
end

puts “Server:”  
server = gets  
puts “dbname:”  
dbname = gets  
puts “Syntax:”  
syntax = gets  
puts “isbn:”  
isbn = gets

zoomreturn(server, dbname, syntax, isbn)

---

<div class="post-metadata">

**Author:** ![johnf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@johnf](https://www.ruby-forum.com/u/johnf)\
**Post date:** [July 18, 2006, 4:58pm UTC](https://www.ruby-forum.com/t/program-works-in-irb-but-not-in-script/98847/2 "2006-07-18T16:58:54Z")

</div>

> > > > > “J” == John F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

Try it with

J\> puts “Server:”  
J\> server = gets

server = gets.chomp

J\> puts “dbname:”  
J\> dbname = gets

dbname = gets.chomp

J\> puts “Syntax:”  
J\> syntax = gets

syntax = gets.chomp

J\> puts “isbn:”  
J\> isbn = gets

isbn = gets.chomp

Guy Decoux

---

<div class="post-metadata">

**Author:** ![johnf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@johnf](https://www.ruby-forum.com/u/johnf)\
**Post date:** [July 18, 2006, 5:05pm UTC](https://www.ruby-forum.com/t/program-works-in-irb-but-not-in-script/98847/3 "2006-07-18T17:05:25Z")

</div>

Holy moley, that works. Retrospectively, what a completely dumb thing I  
did. Of course zoom would choke on newlines. Buh. Guy, thanks a ton;  
I  
appreciate it.

jf
