Hi, I am doing a web-based viewer to read messages sent from a daemon on separate server.
I have a listener script that opens a socket, repeatedly waits for messages to come in and then write to a log file.
I have also a viewer script that reads from the log file and displays the messages on the browser.

I want to allow the user to control the uptime of the listener script. My current idea is to let the user make a cgi request to start the listener script, get the pid and put into a file. When the user make a request to stop listening, the cgi script will read from the file and kill the listener process using the pid.
I intend to try this next Monday but I'm not even sure the cgi script is allowed to kill a process this way.

Can anyone with experience give me some advice or a better approach to doing this?

Currently,the user has to make a request to check for updated logged messages. Is that a way to have the viewer script auto-update the web-page whenever the log file is updated by the listener script? If so, the viewer script also needs to know when the viewer closes the browser window so that it will exit itself right?


In reply to Starting and stopping a listener script from CGI by Eureka_sg

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.