From: "Nation, Carey" Date: 2011-07-20T04:31:36+09:00 Subject: Re: Code works in IRB but not when saved and run (NET/TOC) Irb is keeping the session alive. Maybe it's not working because your script is exiting before it can? -----Original Message----- From: Opviel Krevt [mailto:ovashena@gmail.com] Sent: Tuesday, July 19, 2011 3:28 PM To: ruby-talk ML Subject: Code works in IRB but not when saved and run (NET/TOC) I'm using the net-toc gem to connect to AIM with Ruby 1.8.7 since 1.9.2 doesn't seem to support net-toc. The code below works fine if I input it line by line into IRB, but it won't create a connection and send an IM if I run the code from a file($ ruby aim.rb). I've tried adding sleep(2) after each connection to emulate the time it took me to write each line in IRB, but that didn't work either. Any ideas? #Loads net/toc, aim gem require 'rubygems' require 'net/toc' #Get username, password, buddy's screenname, and message print "username: " username = gets print "password: " password = gets print "buddy's screenname: " screenname = gets print "message: " message = gets #Define TOC Connection client = Net::TOC.new(username, password) #Connect client.connect #Grab object associated with buddy's screenname friend = client.buddy_list.buddy_named(screenname) #Sends the IM friend.send_im(message) -- Posted via http://www.ruby-forum.com/.