Works thro irb but not on commandline

i have a strange prob. when i run this code under irb, the buddy can
recieve the message. when i run it under the ruby commandline, the
buddy does not recive the message. i am not sure what the difference
is.
any pointers is appreciated.

require ‘net/toc’
client = Net::TOC.new(“userid”,“password”)
client.connect
client.wait(10)
friend = client.buddy_list.buddy_named(“mybuddy1”)
client.on_im do | message, buddy |
puts “#{buddy.screen_name}: #{message}”
end
client.on_error do | error |
puts “!! #{error}”
end

friend.send_im(" hi how going") # not sure why this is not being
sent.
puts client.buddy_list.to_s

client.disconnect()

Junkone [email protected] writes:

i have a strange prob. when i run this code under irb, the buddy can
recieve the message. when i run it under the ruby commandline, the
buddy does not recive the message. i am not sure what the difference
is.

Are there any error messages associated with it not working? Have you
checked your ~/.irbrc to make sure there’s nothing in there that would
be letting this work, that you don’t have in the source file you are
trying?

Have you written any test code to show it working vs. not working?

On Apr 24, 4:58 pm, Peter J. [email protected] wrote:

Have you written any test code to show it working vs. not working?


Peter J. [pjones at domain below]
pmade inc. -http://pmade.com

i have the aol im on my machine connected as one of the buddies
i cut and paste the code from the aimbot.rb file and execute them line
by line and when i hit
friend.send_im(" hi how going")
i get the IM on my aol client.

when i execute the aimbot.rb the message does not popup on my aim
client. i get no errors. nothing. beats the hell out of me.

require ‘net/toc’
client = Net::TOC.new(“userid”,“password”)
client.connect
friend = client.buddy_list.buddy_named(“mybuddy”)
friend.send_im(" hi how going")
client.disconnect()

the irb is the same code as above. no typeing. just cut and paste

E:\Documents and Settings\User1>irb
irb(main):001:0> require ‘net/toc’
=> true
irb(main):002:0> client = Net::TOC.new(“userid”,“password”)
=> #<Net::TOC::Client:0x2eadb64 @buddy_list=#<Net::TOC::BuddyList:
0x2eada88 @buddies={}, @group_order=[],
onn=#<Net::TOC::Connection:0x2eadb3c @msgseq=65919,
@user=“trad2win”>>, @screen_name=“trad2win”, @callbac
<Proc:[email protected]:/ruby/lib/ruby/gems/1.8/gems/net-toc-0.2/./net/
toc.rb:436>, :config=>#<Proc:0x02ebb930
by/gems/1.8/gems/net-toc-0.2/./net/toc.rb:436>, :update_buddy=>#<Proc:
[email protected]:/ruby/lib/ruby/gems/1.
0.2/./net/toc.rb:437>, :error=>#<Proc:[email protected]:/ruby/lib/ruby/gems/
1.8/gems/net-toc-0.2/./net/toc.rb:
uddy2=>#<Proc:[email protected]:/ruby/lib/ruby/gems/1.8/gems/net-toc-0.2/./
net/toc.rb:437>}, @password="password::TOC::Connection:0x2eadb3c
@msgseq=65919, @user=“userid”>>
irb(main):003:0> client.connect
=> #<Thread:0x2eab6d4 sleep>
irb(main):004:0> friend = client.buddy_list.buddy_named(“mybuddy”)
=> #<Net::TOC::Buddy:0x2ea8754 @screen_name=“mybuddy”,
@last_signon=Thu Apr 24 15:43:28 -0400 2008,
ble, @on_status={}, @conn=#<Net::TOC::Connection:0x2eadb3c
@msgseq=65923, @user=“userid”, @sock=#<TCPSo

, @idle_time=0, @warning_level=0>
irb(main):005:0> friend.send_im(" hi how going")
=> 47
irb(main):006:0> client.disconnect
=> nil
irb(main):007:0>

On Apr 24, 5:39 pm, dusty [email protected] wrote:

Is net/toc a gem?

try adding

require ‘rubygems’

to the top of the file

nope. it makes no difference. i even opened the gem and added a puts
“i am here” line and can see it sending the message. but the client is
not flashing the mesg if it not from IRB.

strangest thing i have seen.

Is net/toc a gem?

try adding

require ‘rubygems’

to the top of the file

Junkone [email protected] writes:

i have the aol im on my machine connected as one of the buddies
i cut and paste the code from the aimbot.rb file and execute them line
by line and when i hit
friend.send_im(" hi how going")
i get the IM on my aol client.

I don’t think there’s much anyone can do for you until you narrow this
a bit further down.

I honestly think that you should start by writing some tests. If it
were me, I’d use some test code from the gem you are using so that
you didn’t need to use any GUI client to confirm delivery.

I might also write a test that used tcpdump(1) to look for the packets
leaving the interface, and assert that they are actually being sent.

I’m assuming from your connect call that this protocol is based on TCP
and not UDP. At the very least, using tcpdump should help you
understand where the error is, on the sending side or the receiving
side.

Good luck.

On Apr 24, 8:08 pm, Ken B. removed_email_addres[email protected] wrote:

message, buddy |
client.disconnect()

  • Show quoted text -

ok. the sleep worked. that was smart of you.

On Thu, 24 Apr 2008 13:23:28 -0700, Junkone wrote:

message, buddy |
client.disconnect()
Try sleeping for a second after sending the message, but before
disconnecting, and see if that fixes it. (Maybe it’s some kind of
asynchronous communication issue in net/toc.)

–Ken

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs