[英]Windows command prompt creating but not redirecting output to file
我在这里看到的很多帖子都遇到了相反的问题。
我正在运行由其他人编写的 perl 命令,尽管使用了“>”命令,但 output 都被强制显示在屏幕上。
Windows 清楚地知道我的意图,因为每次我执行我的命令时,我给出的文件名都是全新的,但日志文件的内容/大小是空的,长度为 0 字节。
我的 perl 可执行文件与我的 perl 例程/.pl 文件位于不同的位置。
我尝试以管理员身份运行,而不是。
这不是程序有问题。 我的一些同事执行得很好,他们的屏幕上没有 output。
一般语法是:
F:\git\repoFolderStructure\bin>
F:\git\repoFolderStructure\bin>perl alog.pl param1 param2 commaSeparatedParam3 2020-12-17,18:32:33 2020-12-17,18:33:33 > mylogfile.log
>>>>>Lots and lots of output I wish was in a file
Also attempted in the directory with my perl.exe and gave the path to my repo folder's bin.
windows 有什么奇怪的地方可以创建/阻止 > 运算符的行为吗?
这是踢球者:我做了ipconfig > out.txt
就好了,虽然......没有写入屏幕。
感谢您提供有关我可以做些什么来尝试改变行为的任何提示!
可能是 output 正在发送到 STDERR,而您正在捕获 STDOUT。 Append 2>&1
将两者捕获到同一个文件中。
>perl -e"print qq{STDOUT\n}; warn qq{STDERR\n};" >stdout
STDERR
>type stdout
STDOUT
>perl -e"print qq{STDOUT\n}; warn qq{STDERR\n};" 2>stderr
STDOUT
>type stderr
STDERR
>perl -e"print qq{STDOUT\n}; warn qq{STDERR\n};" >stdout 2>stderr
>type stdout
STDOUT
>type stderr
STDERR
>perl -e"print qq{STDOUT\n}; warn qq{STDERR\n};" >both 2>&1
>type both
STDERR
STDOUT
请注意,如果要合并两个流,则2>&1
必须在重定向 STDOUT 之后出现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.