Windows 创建命令提示符但不将输出重定向到文件
Windows command prompt creating but not redirecting output to file
我在这里看到的很多帖子都遇到了相反的问题。
我是 运行 别人写的 perl 命令,尽管使用了“>”命令,但输出都被强制显示在屏幕上。
Windows 清楚地知道我的意图,因为我每次执行命令时都会重新创建我提供的文件名,但日志文件的 contents/size 是空的且为 0字节长。
我的 perl 可执行文件与我的 perl 例程/.pl 文件位于不同的位置。
我试过 运行 作为管理员,但没有。
这不是程序有问题。我的一些同事执行得很好,他们的屏幕上没有输出。
一般语法是:
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 有什么奇怪的地方可以 create/prevent > 运算符的行为吗?
更重要的是:我 ipconfig > out.txt
很好,但是...没有任何内容写入屏幕。
感谢您提供任何提示,告诉我我可以做些什么来尝试改变行为!
可能是在捕获 STDOUT 时将输出发送到 STDERR。附加 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 之后出现。
我在这里看到的很多帖子都遇到了相反的问题。
我是 运行 别人写的 perl 命令,尽管使用了“>”命令,但输出都被强制显示在屏幕上。
Windows 清楚地知道我的意图,因为我每次执行命令时都会重新创建我提供的文件名,但日志文件的 contents/size 是空的且为 0字节长。
我的 perl 可执行文件与我的 perl 例程/.pl 文件位于不同的位置。
我试过 运行 作为管理员,但没有。
这不是程序有问题。我的一些同事执行得很好,他们的屏幕上没有输出。
一般语法是:
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 有什么奇怪的地方可以 create/prevent > 运算符的行为吗?
更重要的是:我 ipconfig > out.txt
很好,但是...没有任何内容写入屏幕。
感谢您提供任何提示,告诉我我可以做些什么来尝试改变行为!
可能是在捕获 STDOUT 时将输出发送到 STDERR。附加 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 之后出现。