I have a Perl script that runs as an ExternalTask on Windows 2000. The task XML contains this command line:
<command v="C:\iw-home\iw-perl\bin\iwperl C:\iw-home\custom\bin\CommandWrapper.ipl -c generate lock email -i"/>
The script contains the following code:
sub localLog
{
if ( ! open( LOG, ">>${logfile}" ))
{
die( "Unable to open ${logfile} for write : $!" );
}
while( my $line = shift(
@_ ))
{
print LOG scalar( localtime( time())) . " ${line}\n";
}
close( LOG );
}
my ${command} = "${iwhome}${slash}bin${slash}iwconfig pioneer java_home";
localLog( "Command : ${command}" );
localLog( "Result without redirect: " . `${command}` );
localLog( "Result with redirect: " . `${command} 2>&1` );
What appears in the log file after this externaltask executes is this:
Thu Apr 10 15:42:35 2003 Configurable: C:\j2sdk1.4.1_01
Thu Apr 10 15:42:35 2003 Command : c:\iw-home\bin\iwconfig pioneer java_home
Thu Apr 10 15:42:35 2003 Result without redirect: C:\iw-home\tools\java1.3
Thu Apr 10 15:42:35 2003 Result with redirect:
Note that when STDERR is redirected, the value does not appear. When I run this script on the command line (as opposed to as an ExternalTask) the output is as follows:
Thu Apr 10 15:39:14 2003 Configurable: C:\iw-home\tools\java1.3
Thu Apr 10 15:39:14 2003 Command : c:\iw-home\bin\iwconfig pioneer java_home
Thu Apr 10 15:39:14 2003 Result without redirect: C:\iw-home\tools\java1.3
Thu Apr 10 15:39:14 2003 Result with redirect: C:\iw-home\tools\java1.3
Note that the value of the configurable appears even when STDERR is redirected. Does anyone know why this is happening and how it can be avoided? I always want to trap STDERR when I run command lines.
Thanks & regards,
-John