Take a look at perlman:perlipc with particular reference to the Named-pipe or Unix-Domain TCP Clients and Servers for some simple client and server code samples. A bit further down there is a section on UDP: Message Passing, which would be ideal for your application.

You could also read the IO::Sockets documentation.

Essentially, your current cron job script would need to open a socket using the UDP protocol on localhost:someport, (where someport is probably >1024.)

This would take the place of opening the file in your current script.

You would then wrap an endless loop around the processing code in your current script and before where you are currently reading from a file you would block waiting for input. When the input arrives, read it, process it and loop back to listen again.

Where you existing cgi script open and writes to the file, you would connect to localhost:someport (udp), send() the data and close the port.

I don't recall seeing a UDP server example in perlman:perlipc but its not very different to the TCP server. Maybe there is a good example in IO::Socket docs.


What's this about a "crooked mitre"? I'm good at woodwork!

In reply to Re: Re: Re: Script run as a Cron Job by BrowserUk
in thread Script run as a Cron Job by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.