Hi delpi,

Without knowing anything about the server, it's a little difficult to give a good answer, also you don't tell us how you know your Perl script isn't working - e.g. you could have it write debug output to a separate logfile.

Anyway, I have two ideas. First, if you can get the server to write its output to a log file which you can then view live with tail, you can do the same with Perl, with the module File::Tail. That has the advantage of decoupling the two processes, at the expense of a small bit of performance.

Second, you could try invoking the server with something like IPC::Run, which can communicate with the subprocess interactively. The disadvantage is that now the server is a subprocess of the Perl script, which might not work if, for example, the server tries to detach itself and go into the background (daemonize). Anyway, a simple example:

use IPC::Run qw/run/; run ['/path/to/server'], \undef, sub { my $in = shift; chomp($in); print "<<$in>>\n"; };

However, depending on how the server is implemented, this solution may still suffer from buffering.

Hope this helps,
-- Hauke D


In reply to Re: Redirect Shell Launch to perl script by haukex
in thread (solved) Redirect Shell Launch to perl script by delpi

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.