Sorry for cross-posting, but Im unsure if this is a ActivePerl or general
Win32 perl issue.
Accourding to perldoc -q "how can i capture stderr":
With system(), both STDOUT and STDERR will go the same place as
the script's STDOUT and STDERR, unless the system() command
redirects them. Backticks and open() read only the STDOUT of
your command.
This seems to be untrue (or they are going to the same place, but not passed
into the scripts STDOUT and STDERR) when using Win32.
CADRC::Build::LogFile is a tie module I wrote to print to screen and print
to file at the same time.
Consider the following code:
#!/usr/bin/perl
# Author: Matthew Walkup
# Single Vessel Update
use CADRC::Build;
use CADRC::Build::LogPrint;
use Win32API::File 0.08 qw( :ALL );
print "print test 1\n";
tie *STDERR, 'CADRC::Build::LogPrint', 'logfile.txt', "[\%\%time\%\%]
ERROR:\t", 'test: ';
tie *STDOUT, 'CADRC::Build::LogPrint', 'logfile.txt',
"[\%\%time\%\%]:\t\t", 'Test: ';
warn "Warn test 1\n";
print STDOUT "direct out test 2\nTesting 1 2 3";
print STDERR "direct error test 2\n";
print TEST "direct test test\n";
print STDOUT "direct out test 3\n";
print STDOUT "direct out test 4\n";
print STDERR "direct error test 3\n";
print STDERR "direct error test 4\n";
__END__
The output to the screen is the following (which is correct):
print test 1
Warn test 1
Test: direct out test 2
Test: Testing 1 2 3
test: direct error test 2
Test: direct out test 3
Test: direct out test 4
test: direct error test 3
test: direct error test 4
Now, by adding a system("echo testing 1 2 3"); at the end, it does not work
(it simply prints testing 1 2 3 without prefixing it with 'test: ').
Heres my point. Is there a way to redirect a file-descriptor that contains
the STDERR and STDOUT of the file. The best way is to extract an equivelent
FileHandle object or type glob (that is a handler) and simply tie the
equivilent object.
However, I have been unable to extract a FileHandle object or type glob.
Ive tried several functions:
*TEST90 = FdGetOsFHandle(0);
*TEST0 = OsFHandleOpenFd(0, 0);
OsFHandleOpen(TEST0, 0, 0);
Then tying:
tie *TEST0, 'CADRC::Build::LogPrint', 'logfile.txt', "[\%\%time\%\%]:\t\t",
'Test 0: ';
and then running the system call.
Ive tried file descripters 0-10, though I understand 0-2 are the normal
outputs.
Any hints or suggestions will be greatly appreciated.
Thank you,
Matthew Walkup
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs