views:

3122

answers:

1

I tried this:

test1.pl >output.log 2>&1

but this is the result:

Can't dup STDOUT:  Permission denied at C:/Perl/lib/Test/Builder.pm line 1376.
Compilation failed in require at C:/Perl/lib/Test/Builder/Module.pm line 3.
BEGIN failed--compilation aborted at C:/Perl/lib/Test/Builder/Module.pm line 3.
Compilation failed in require at C:/Perl/lib/Test/More.pm line 22.
BEGIN failed--compilation aborted at C:/Perl/lib/Test/More.pm line 22.
Compilation failed in require at C:/Perl/site/lib/Test/WWW/Selenium.pm line 72.
BEGIN failed--compilation aborted at C:/Perl/site/lib/Test/WWW/Selenium.pm line 72.
Compilation failed in require at C:\Software\selenium-remote-control-1.0-beta-2\tests\test1.pl line 5.
BEGIN failed--compilation aborted at C:\Software\selenium-remote-control-1.0-beta-2\tests\test1.pl line 5.

The script runs file as long as I don't try to redirect the output from the command line in any way.

Here's my script, just in case that helps. (It's a Selenium test script):

#!C:/perl/bin/perl.exe -w
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;

my $sel = Test::WWW::Selenium->new( host => "localhost", 
                                    port => 4444, 
                                    browser => "*chrome", 
                                    browser_url => "http://localhost/" );
print "Start Time: " . localtime() . "\n";
for (my $count = 3000; $count > 0; $count--)
{
print $count . " tests remaining.\n";
   $sel->open_ok("/home");
   $sel->click_ok("link=News");
   $sel->wait_for_page_to_load_ok("30000");
   $sel->click_ok("video");
   $sel->wait_for_page_to_load_ok("30000");
   $sel->click_ok("link=Sports");
   $sel->wait_for_page_to_load_ok("30000");
   $sel->click_ok("link=Movies");
   $sel->wait_for_page_to_load_ok("30000");
   $sel->click_ok("moremovies");
   $sel->wait_for_page_to_load_ok("30000");
}

print "End Time: " . localtime() . "\n";
+8  A: 

There is general problem with redirection in Perl for Windows.

The line that fails in Test::More package says:

open TESTOUT, ">&STDOUT" or die $!;

This fails when you invoke command as test.pl > outlog.log, as the file that you are redirecting STDOUT to is locked by cmd.exe, not by perl.exe. You cannot dup() it from perl.exe

You need to run:

perl test1.pl >output.log 2>&1`

instead.

Quassnoi
In general, you will always need to run `perl foo.pl` instead of just `foo.pl` for redirections to work properly -- it's not specific to this case. Windows blargh.
ephemient