Redirecting output

K

kvrnkiran

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.
 
P

Paul Lalli

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
 
J

Joe Smith

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
 
K

kvrnkiran

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.
 
P

Paul Lalli

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top