Windows命令提示符创建但不将输出重定向到文件



我遇到了与我在这里看到的许多帖子相反的问题。

我正在运行一个由其他人编写的perl命令,尽管使用了">quot;命令

Windows清楚地知道我的意图,因为每次我执行命令时,我提供的文件名都是全新创建的,但日志文件的内容/大小是空的,长度为0字节。

我的perl可执行文件与perl例程/.pl文件位于不同的位置。

我试着以管理员身份运行,但没有。

这不是程序出了什么问题。我的一些同事执行得很好,屏幕上没有输出。

一般语法为:

F:gitrepoFolderStructurebin>
F:gitrepoFolderStructurebin>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.

窗口是否有一些奇怪的东西可以创建/阻止>操作员行为?

关键是:虽然ipconfig > out.txt我做得很好。。。屏幕上没有任何内容。

谢谢你给我的任何建议,我可以做些什么来尝试和改变这种行为!

可能是在捕获STDOUT时,输出被发送到STDERR。附加2>&1以将两者捕获到同一文件中。

>perl -e"print qq{STDOUTn}; warn qq{STDERRn};" >stdout
STDERR
>type stdout
STDOUT
>perl -e"print qq{STDOUTn}; warn qq{STDERRn};" 2>stderr
STDOUT
>type stderr
STDERR
>perl -e"print qq{STDOUTn}; warn qq{STDERRn};" >stdout 2>stderr
>type stdout
STDOUT
>type stderr
STDERR
>perl -e"print qq{STDOUTn}; warn qq{STDERRn};" >both 2>&1
>type both
STDERR
STDOUT

请注意,如果要合并两个流,则重定向STDOUT之后必须出现2>&1

最新更新