Loading ...
Sorry, an error occurred while loading the content.

Re: How to send the STDOUT to a File

Expand Messages
  • Damien Carbery
    ... A non-perl solution could be to use the tee (http://unixhelp.ed.ac.uk/CGI/man-cgi?tee or man tee ). This utility is available on Unix (and Windows via
    Message 1 of 2 , Sep 25, 2005
    • 0 Attachment
      --- In perl-beginner@yahoogroups.com, "Bobby Jafari"
      <bobby.jafari@s...> wrote:
      > Hi All,
      >
      > I am using the Test::More and Test:Harness modules in my test scripts. I
      > need to be able to log results into files. What the best way to captures
      > the STDOUT output from ok and other Test::More functions. I need to view
      > STDOUT as well as capture it into a file so that the files can be used
      > as test results.
      >
      > Sample code:
      > ------------------------------------------------------------------------
      > ---------
      > #!/usr/bin/perl
      > use warnings;
      > use strict;
      > use Test::More qw(no_plan);
      > use Test::Harness;
      > # Global Variables
      > use vars qw($Host $Port $FileName $TestName $TestResult $Loging
      > $EchoState);
      > require "senetasLIB.pl";
      > my $Failures = 0;
      > my $OS = GetOS ();
      > print $OS;
      > print "\n";
      > if ( Same failure condition)
      > {
      > $Failures = $Failures + 1;
      > }
      > ok ("$Failures = 0", "Test Case Has PASSED");
      > ------------------------------------------------------------------------
      > ---------------------
      > I get the correct information sent to STDOUT. I also need to be able log
      > info to files so that I can use them as test logs. (I.E to send to
      > customers as proof that the tests was performed on products)
      >
      > Any input is welcome. Thanks in advance for your input.
      >
      > Regards,
      > Bobby
      >
      >
      A non-perl solution could be to use the 'tee'
      (http://unixhelp.ed.ac.uk/CGI/man-cgi?tee or 'man tee').
      This utility is available on Unix (and Windows via cygwin).

      Usage: ./your_script.pl | tee logfile.txt
    Your message has been successfully submitted and would be delivered to recipients shortly.