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

Re: How to capture the output of Module

Expand Messages
  • vishal_kharge
    Hello, Thanks, But here you are creating a new .pl file ie. ... I don t want to create the new file. ... 0.61
    Message 1 of 4 , Aug 8, 2005
    • 0 Attachment
      Hello,

      Thanks, But here you are creating a new .pl file ie.

      > The same in perl:
      > #!/usr/bin/perl -w
      > use strict;
      >
      > # capture entire output in a variable:
      > my $captured_output = `perl Harness.pl 2>&1`;
      > # or, each output line in a list element:
      > my @captured_output = `perl Harness.pl 2>&1`;

      I don't want to create the new file.

      Is there any options or modification in the following code:

      > > #!/usr/bin/perl
      > > use Test::Harness;
      > > runtests"Backtick1.pl";

      ******************************************************************
      --- In perl-beginner@yahoogroups.com, "Damien Carbery"
      <daymobrew@y...> wrote:
      > --- In perl-beginner@yahoogroups.com, "vishal_kharge"
      > <vishal_kharge@y...> wrote:
      > > Hello All:
      > >
      > > I am using a Module Test::Harness
      > >
      > > Below is my Code for Harness.pl:
      > > #!/usr/bin/perl
      > > use Test::Harness;
      > > runtests"Backtick1.pl";
      > >
      > > --------------------
      > > Backtick1.pl is an perl code for doing some task.
      > >
      > > When I run the Harness.pl as shown below:
      > > [guest@qdi Code]$ perl Harness.pl
      > > Backtick1.p.........ok
      > > All tests successful.
      > > Files=1, Tests=22, 1 wallclock secs ( 0.47 cusr + 0.14 csys =
      0.61
      > > CPU)
      > > [guest@qdi Code]$
      > >
      > > Now I want to capture the output of Harness.pl
      > >
      > > How should I proceed?
      > >
      > > Thanks,
      > > Vishal Kharge
      >
      > Mmm, this question seems strangely familar..
      > and so is the answer:
      > http://groups.yahoo.com/group/perl-beginner/message/21561
      >
      > Capture output:
      > [guest@qdi Code]$ perl Harness.pl >captured_output.pl
      >
      > Capture output including errors:
      > [guest@qdi Code]$ perl Harness.pl >captured_output.pl 2>&1
      >
      > The same in perl:
      > #!/usr/bin/perl -w
      > use strict;
      >
      > # capture entire output in a variable:
      > my $captured_output = `perl Harness.pl 2>&1`;
      > # or, each output line in a list element:
      > my @captured_output = `perl Harness.pl 2>&1`;
      >
      > Why are you asking this again? Did my previous answer not work for
      > you? Did you not understand it?
    • Damien Carbery
      ... Just add the following to the above code: # capture entire output in a variable: my $captured_output = `perl Backtick1.pl 2 &1`; print
      Message 2 of 4 , Aug 8, 2005
      • 0 Attachment
        --- In perl-beginner@yahoogroups.com, "vishal_kharge"
        <vishal_kharge@y...> wrote:
        > Hello,
        >
        > Thanks, But here you are creating a new .pl file ie.
        >
        > > The same in perl:
        > > #!/usr/bin/perl -w
        > > use strict;
        > >
        > > # capture entire output in a variable:
        > > my $captured_output = `perl Harness.pl 2>&1`;
        > > # or, each output line in a list element:
        > > my @captured_output = `perl Harness.pl 2>&1`;
        >
        > I don't want to create the new file.
        >
        > Is there any options or modification in the following code:
        >
        > > > #!/usr/bin/perl
        > > > use Test::Harness;
        > > > runtests"Backtick1.pl";

        Just add the following to the above code:

        # capture entire output in a variable:
        my $captured_output = `perl Backtick1.pl 2>&1`;
        print "Output:\n$captured_output";
        # or, each output line in a list element:
        my @captured_output = `perl Backtick1.pl 2>&1`;
        print "Output:\n", join( '', @captured_output );

        >
        > ******************************************************************
        > --- In perl-beginner@yahoogroups.com, "Damien Carbery"
        > <daymobrew@y...> wrote:
        > > --- In perl-beginner@yahoogroups.com, "vishal_kharge"
        > > <vishal_kharge@y...> wrote:
        > > > Hello All:
        > > >
        > > > I am using a Module Test::Harness
        > > >
        > > > Below is my Code for Harness.pl:
        > > > #!/usr/bin/perl
        > > > use Test::Harness;
        > > > runtests"Backtick1.pl";
        > > >
        > > > --------------------
        > > > Backtick1.pl is an perl code for doing some task.
        > > >
        > > > When I run the Harness.pl as shown below:
        > > > [guest@qdi Code]$ perl Harness.pl
        > > > Backtick1.p.........ok
        > > > All tests successful.
        > > > Files=1, Tests=22, 1 wallclock secs ( 0.47 cusr + 0.14 csys =
        > 0.61
        > > > CPU)
        > > > [guest@qdi Code]$
        > > >
        > > > Now I want to capture the output of Harness.pl
        > > >
        > > > How should I proceed?
        > > >
        > > > Thanks,
        > > > Vishal Kharge
        > >
        > > Mmm, this question seems strangely familar..
        > > and so is the answer:
        > > http://groups.yahoo.com/group/perl-beginner/message/21561
        > >
        > > Capture output:
        > > [guest@qdi Code]$ perl Harness.pl >captured_output.pl
        > >
        > > Capture output including errors:
        > > [guest@qdi Code]$ perl Harness.pl >captured_output.pl 2>&1
        > >
        > > The same in perl:
        > > #!/usr/bin/perl -w
        > > use strict;
        > >
        > > # capture entire output in a variable:
        > > my $captured_output = `perl Harness.pl 2>&1`;
        > > # or, each output line in a list element:
        > > my @captured_output = `perl Harness.pl 2>&1`;
        > >
        > > Why are you asking this again? Did my previous answer not work for
        > > you? Did you not understand it?
      Your message has been successfully submitted and would be delivered to recipients shortly.