如何将stdout和stderr输出从Perl脚本重定向到Windows上的文件?
发布时间:2020-12-15 23:24:45 所属栏目:大数据 来源:网络整理
导读:我试过这个: test1.pl output.log 21 但这是结果: 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
我试过这个:
test1.pl >output.log 2>&1 但这是结果: 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:Softwareselenium-remote-control-1.0-beta-2teststest1.pl line 5. BEGIN failed--compilation aborted at C:Softwareselenium-remote-control-1.0-beta-2teststest1.pl line 5. 只要我不尝试以任何方式重定向命令行的输出,脚本就会运行文件. 这是我的脚本,以防万一. (这是一个Selenium测试脚本): #!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"; 解决方法
在Perl for Windows中重定向存在一般问题.
Test :: More包中失败的行说: open TESTOUT,">&STDOUT" or die $!; 当您以test.pl>调用命令时,这会失败outlog.log,因为您重定向STDOUT的文件被cmd.exe锁定,而不是由perl.exe锁定.你不能从perl.exe复制()它 你需要运行: perl test1.pl >output.log 2>&1 代替. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |