Wise ones, I have a dilemma.

Quick and dirty explaination: I need a way of splitting STDERR
in the same way that the /bin/tee command splits STDOUT.

I am using Net::FTP to login and retrieve a file from a VAN, (value added network). After retrieving data the VAN returns a line

Total bytes retrieved: 0        stored: 0
... I need to be able to "catch" this line in a logfile AND still have the messages send to STDERR.

I am using Debug => 1 when I call Net::FTP

use Net::FTP; $ftp = Net::FTP->new("servername", Debug => 1); $ftp->login("username","passwd"); $ftp->message(); $ftp->cwd("/tmp"); $ftp->get("some.file"); print "get returned: $ftp\n"; $ftp->quit;

So, the line that I mention above is returned to STDERR, just as perldoc.com documentation says. My problem is that I need to be able to BOTH, have this information printed to STDERR for my system to log it AND be able to capture this data in a separate logfile that my Operations group can monitor.

As you can see from the code above, I have tried using message(), inherited from Net::Cmd, and printing the value of $ftp. However, these options only print the Net::FTP=GLOB(0x226c14) value of the command, I need the text messages.

I have tried using filehandles and several other creative, but unsuccessful options.

I can easily redirect STDERR to a file, or allow STDERR to operate normally, but I have not been able to get BOTH to work. Please help if you can.

Edited: Fri Jun 21 15:12:08 2002 (GMT), by Footpad: Fixed broken </CODE> tag and modified HTML Formatting to improve XML compatibility.


In reply to Splittig STDERR output to file AND STDERR by cybear

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.