Redirecting output

Discussion in 'Perl Misc' started by kvrnkiran@gmail.com, Jul 7, 2005.

  1. Guest

    Hi Everybody,

    I am a new-bee in PERL. Basically, I am a VC++ programmer. I am in the
    process of running PERL script from my VC++ code. I have completed this
    task succcessfully. Now, I am facing a problem. As I am running my perl
    script from my executable, I am unable to get any of the messages
    displayed by perl compiler, like compiler errors, print outputs etc. To
    be specific, any messages to stdout and stderr.

    Is there a way to capture those messages? Can anybody help me?

    Thanks for your time.

    KVRN Kiran Kumar.
    , Jul 7, 2005
    #1
    1. Advertising

  2. Paul Lalli Guest

    wrote:
    > Hi Everybody,
    >
    > I am a new-bee in PERL.


    Then you would do well to read some of the FAQs with come with Perl.
    Starting with
    perldoc -q difference
    "What is the difference between 'Perl' and 'perl'?"

    > Basically, I am a VC++ programmer. I am in the
    > process of running PERL script from my VC++ code. I have completed this
    > task succcessfully. Now, I am facing a problem. As I am running my perl
    > script from my executable, I am unable to get any of the messages
    > displayed by perl compiler, like compiler errors, print outputs etc. To
    > be specific, any messages to stdout and stderr.
    >
    > Is there a way to capture those messages? Can anybody help me?


    If I understand correctly what you're asking, I don't believe this
    question has anything to do with Perl. It has to do with whatever
    language the parent program is written in, which you say is C++. You
    can tell it has nothing to do with Perl because the question would be
    the same no matter what language the child program is written in.

    What you need to do is figure out how to capture STDOUT and STDERR by
    whatever method your C++ executable is calling a child process. For
    that, I would suggest asking one of the C++ newsgroups, instead of the
    Perl newsgroup.

    If, on the other hand, you are attempting to redirect the Perl
    program's STDOUT and STDERR from within the Perl program itself, you
    can do it like so:

    open STDOUT, '>>', 'outfile.txt' or die "Can't redirect STDOUT: $!";
    open STDERR, '>>', 'errfile.txt' or die "Can't redirect STDERR: $!";

    >From that point on, all prints and warnings that the Perl script (but

    not the perl interpreter that runs your Perl script!) generates will be
    directed to the files outfile.txt and errfile.txt, respectivly.

    Paul Lalli
    Paul Lalli, Jul 7, 2005
    #2
    1. Advertising

  3. Joe Smith Guest

    wrote:
    > I am unable to get any of the messages
    > displayed by perl compiler, like compiler errors, print outputs etc. To
    > be specific, any messages to stdout and stderr.


    Have you tried the obvious?

    Start->Run->cmd
    C:\>perl myprogram.pl

    The first step creates a window in which STDOUT and STDERR can be
    displayed. Is that what you want?

    Otherwise you'll need to check the VC++ documentation on how
    to invoke an external program in such a way that the program's
    STDERR and STDOUT are readable from VC++.
    -Joe
    Joe Smith, Jul 10, 2005
    #3
  4. Guest

    Dear Paul,

    Thank you for your reply. I think, you are correct. It might not be
    related to PERL. I will look into VC++ end to resolve this issue.

    Thank you once again for your time.

    Regards,
    KVRN Kiran Kumar.
    , Jul 12, 2005
    #4
  5. Paul Lalli Guest

    wrote:
    > Dear Paul,
    >
    > Thank you for your reply. I think, you are correct. It might not be
    > related to PERL. I will look into VC++ end to resolve this issue.
    >
    > Thank you once again for your time.


    The best way of thanking me would be to first read the Posting
    Guidelines for this group (which would have instructed you to quote an
    appropriate amount of context in your reply) and to second read the
    Perl FAQ I asked you to read in my initial reply (which would have
    educated you as to why "PERL" is never a correct way of spelling
    "Perl").

    Paul Lalli
    Paul Lalli, Jul 12, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Aspinall
    Replies:
    0
    Views:
    363
    Paul Aspinall
    Feb 26, 2006
  2. Olivier Merigon

    Textfield output redirecting

    Olivier Merigon, May 3, 2004, in forum: Java
    Replies:
    1
    Views:
    913
  3. Birch
    Replies:
    3
    Views:
    1,017
    Birch
    Oct 21, 2003
  4. Eddie Parker

    RE: Redirecting system output quietly

    Eddie Parker, Nov 16, 2004, in forum: Python
    Replies:
    4
    Views:
    401
    Donn Cave
    Nov 16, 2004
  5. MrBlueSky
    Replies:
    2
    Views:
    347
    MrBlueSky
    May 10, 2006
Loading...

Share This Page