Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Net::AIM with another script?

by hoopsbwc34 (Initiate)
on Aug 15, 2003 at 07:07 UTC ( [id://284097]=perlquestion: print w/replies, xml ) Need Help??

hoopsbwc34 has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that parses a website for data and prints out some HTML. I call this script every 15 minutes via cron. I want to modify it so that it will send me an IM when it completes but I ran into some problems:

First, I included Net::AIM in the script itself so it would connect send me the HTML and disconnect. GREAT! But, of course, doing this every 15 minutes got me locked out of AOL (at least temporarily)

So I thought it would be better to start up an AOL bot that is always running (eventually could respond to IM from me as well.) But then how do I get the data from my script that is running every 15 minutes from cron? The length of time it takes for this script to run is varied so I'd rather not just sleep 900 and I'd like to always run every 15 minutes.

I don't really want to dump it to a file and read in the file, I want it to be more expansive than that (maybe even support multiple users eventually which would require I send a username and the message to my AIMbot) I thought about opening a socket, but that seemed stupid as I'm on the same machine. LOL... I also thought about forking one of the processes, but I'm not sure what that means :-) or if it would do any good because I would again lose control of my cron start times

So is there a relatively easy way to do this that I'm missing?

Replies are listed 'Best First'.
Re: Net::AIM with another script?
by benn (Vicar) on Aug 15, 2003 at 11:13 UTC
    You could possibly replace Net::Aim with Net::Jabber (and run your own Jabber server) - then you won't fall victim to any AOL policies.

    Cheers, Ben.

Re: Net::AIM with another script?
by eric256 (Parson) on Aug 15, 2003 at 13:49 UTC

    You could run it all in one script and use POE for the timeing. Its not very accurate but i think on the 15 minute scale it would work pretty good. Then you set your bot up as one poe event (calling $aim->do_one_loop continualy) and your other script as an event that repeats every 15 minutes. You might have to record the start time of your HTML grab, and the end time, and figure out the next delay from that, not sure but trivial either way. Good Luck!

    ___________
    Eric Hodges
      Eric, I haven't heard of POE, but I think that might work. I checked out poe.perl.org, but I'm still not sure how I would code this (or what classes I would need, there seem to be a lot).

      Also, I was wondering which you thought would be less server intensive. Running one POE perl script all the time, or using cron to call the scripts only when I want it?

      Would it be better to just include my other script as a subroutine that returns the HTML I wish to send and the AOL username I wish to send it to?

      Thanks!

      One other question. How will I actually get the data to the AIMbot? I somehow need the connection pointer (which is now running in a different script?). Once I do a $aim->start; I'm in an infinite loop ($aim->do_one_loop), and I can't execute any other code UNLESS I get an event off the toc server.... how can POE help me do this? Thanks again.

        Instead of running start, run do_one_loop, in a continous set of poe events.

        I would just include any HTML generation as part of the same script, if you want it to happen at set intervals then use POE to do it.

        For learning poe i would just set it up on a computer, and have it print something every 5 seconds, and then figure out how to get it to print one thing every 5 seconds and another every 7, then you basicaly have the base for what you need. Fix the intervals and have one generate HTML and the other call do_one_loop. Its realy easier than it sounds once you get poe running.

        ___________
        Eric Hodges

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2024-04-18 08:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found