With STDOUT tied to my object I run the comand:
open(SYSTEM, join(" ",
                qq|compile|,
                qq|"$setupRule"|,
                qq|"D:\\InstallShield\\InstallShield Professional
6\\Script\\Ifx\\Lib\\Ifx.obl"|,
                qq|"D:\\InstallShield\\InstallShield Professional
6\\Script\\Isrt\\Lib\\Isrt.obl"|,
                qq|-I"ICODES V5\\Script Files;D:\\InstallShield\\InstallShield
Professional 6\\Script\\IFX\\Include;D:\\InstallShield\\InstallShield
Professional 6\\Script\\ISRT\\Include"|
)." |");
while(<SYSTEM>) {
        print $_;
}

This seems to work great except for a few lines of the output.  My script
prefixes captured output with " testing: " and the line above gives the
number of characters caputred...

Im capturing (18):
 testing:  Compiling All...
Im capturing (34):
 testing: InstallShield (R) Script Compiler
Im capturing (12):
 testing: Version ...
Im capturing (51):
 testing: Copyright (C) - InstallShield Software Corporation
Im capturing (13):
 testing: Compiling...
Setup.rul
Im capturing (11):
 testing: Linking...
Setup.inx - 0 error(s), 0 warning(s)

You can clearly see it does not capture the lines "Setup.rul" and
"Setup.inx - 0 errors(s), 0 warnings(s)" (probably the most important line
of output anyways).

Any ideas or suggestions as to why those lines are the only ones not
captured (consistantly, I ran several test runs).  Or if you have another
idea for implementation, please let me know! :)

Thanks,

Matt


> -----Original Message-----
> From: Matthew Walkup [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 08, 2003 10:34 AM
> To: Matthew Walkup
> Cc: [EMAIL PROTECTED];
> [EMAIL PROTECTED]
> Subject: RE: Problem with perl and system calls
>
>
> 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
>
>
>
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to