繁体   English   中英

如何将Windows命令提示符下发出的命令的Perl脚本输出重定向到文本文件

[英]How to redirect the Perl script output from command issued in windows command prompt to text file

我是Perl的新手,我通过执行以下操作在Windows 7的CommandPrompt对话框中执行.pl文件:

c:\perlscripts\runReport.pl 5 

除了在CommandPrompt对话框中看到输出之外,还有一种方法可以将输出重定向到文本文件吗?

任何帮助/方向将不胜感激。 问候。

如果将'> filename.txt'附加到您的行,它会将结果输出到文件中。 如果您想同时执行这两项操作,则可以在http://code.google.com/p/wintee/上找到 wintee实用程序。 如果它类似于UNIX tee,那么使用它应该只需要你追加'| tee filename.txt'到你的专线。

而不是在命令行中打印输出。 您可以将输出写入文件中。

# Opening file to write the program's output. 
open(FH, ">myFile.txt") or die "Cannot open myFile.txt";

# include module to dump output.
use Data::Dumper;
print FH Dumper(@output);

close FH;

否则你可以像这样写:

perl my_script.pl > myFile.txt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM