Do you get any errors?

Do you have both 1.8.7 and 1.9.2 installed?  If so, maybe you're using two
different versions--add "puts RUBY_VERSION" variable in irb and your rb
file.

My other guess would be that you might need something like EventMachine to
handle asynchronous events, but I would look into the simpler solutions
first.

On Tue, Jul 19, 2011 at 12:28 PM, Opviel Krevt <ovashena / gmail.com> wrote:

> 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/.
>
>