[英]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.