Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Hanging program

by Anonymous Monk
on Apr 11, 2003 at 02:40 UTC ( #249789=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

The program below hangs was an infite time after you supply the second line of input. It doesn't pop up an error, the program just kind of halts but still does something in the background. Anyone know why that doesn't happen/know if this is the only reason messages send?
#!/usr/bin/perl use strict; use warnings; my $user = "wfgs343R"; my $pass = "iamcool"; my $aim; print "Subject's Name:"; chomp(my $destuser = <STDIN>); print "Message:"; chomp(my $message = <STDIN>); use Net::AOLIM; $aim = Net::AOLIM->new( 'username' => $user, 'password' => $pass, 'callback' => \&callbackfunction, 'server' => 'toc.oscar.aol.com', 'port' => 1234, 'allow_srv_settings' => 1, 'login_server' => 'login.oscar.aol.com', 'login_port' => 5198, 'login_timeout' => 0, 'aim_agent' => "$Net::AOLIM::VERSION"); $aim->signon; $aim->toc_send_im($destuser, $message); print "Done\n";

Comment on Hanging program
Download Code
Re: Hanging program
by Improv (Pilgrim) on Apr 11, 2003 at 02:47 UTC
    Try putting some print statements at useful points in your program, e.g.
    • Before $aim gets a value
    • Before $aim->signon
    • Before $aim->toc_send_im()
    That at least will tell you what method is failing, and with that information, we might be able to help you more.
      Program dies after "Information is being passed.". Does this help?
      #!/usr/bin/perl use strict; use warnings; my $user = "wfgs343R"; my $pass = "iamcool"; my $aim; print "Subject's Name:"; chomp(my $destuser = <STDIN>); print "Message:"; chomp(my $message = <STDIN>); use Net::AOLIM; $aim = Net::AOLIM->new( 'username' => $user, 'password' => $pass, 'callback' => \&callbackfunction, 'server' => 'toc.oscar.aol.com', 'port' => 1234, 'allow_srv_settings' => 1, 'login_server' => 'login.oscar.aol.com', 'login_port' => 5198, 'login_timeout' => 0, 'aim_agent' => "$Net::AOLIM::VERSION"); print "Information is being passed.\n"; $aim->signon; print "Aim is signed on.\n"; $aim->toc_send_im($destuser, $message); print "Done\n";
        You are missing () after $aim->signon I dont know if this makes a difference honestly. You should check the return value of signon, when I ran your code, (with my aim of course) the return value of signon was undef (which the docs say means it failed). According to the documentation there are some error messages you can get back (IM_ERR). Try printing those out.
        Also, it takes about thirty or forty seconds for the signon to fail, are you waiting long enough?
        Good luck,
        Josh
Re: Hanging program
by jasonk (Parson) on Apr 11, 2003 at 02:56 UTC

    It isn't giving you an error because it's doing exactly what it is supposed to do, it will sit forever and wait for someone to send it an IM, then it will pass that message to the sub you specified in the callback argument.

    Update: My bad, I thought you had called ui_dataget, which waits for an incoming packet, but you didn't, so this is the wrong answer...

    More useful update: Your aim_agent value has a different format than the default, and the docs say that "There have been some reports that changing this may cause TOC servers to stop responding to signon requests", which seems to be the case, if I remove the aim_agent line from your constructor, it works.


    We're not surrounded, we're in a target-rich environment!
      You're right, that solves one of the two problems I have (I was hoping there'd be only one but now it's obvious I was wrong, sigh). I couldn't get the default agent to work so a monk told me a day or two ago to change it to this line, guess that line didn't work either.

      The new problem is it's printing all my test messages but still not sending messages to the $destuser . Could this be because I have a real version of AIM open to the $destuser account and I'm trying to connect from command line as a different user?

      Thanks for all your help.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://249789]
Approved by sulfericacid
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-09-20 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls