考慮以下兩種情況:a)關閉輸出重定向和b)Rscript輸出重定向到文件out.txt兩種情況下的輸出都在STDOUT中看到,未能重定向到文件輸出.txt僅適用於場景b。我在這裏錯過了什麼,或者這是Rscript.exe特有的嗎?MS DOS命令行輸出重定向到文件不會產生輸出
C:\>C:\\WINDOWS\\system32\\shutdown.exe -t:30 > out.txt
C:\>dir out.txt
Volume in drive C has no label.
Volume Serial Number is 3568-1B07
Directory of C:\
07/18/2012 07:43 PM 841 out.txt
1 File(s) 841 bytes
0 Dir(s) 17,618,206,720 bytes free
C:\>G:\\Progra~1\\R\\R-2.14.0\\bin\\Rscript.exe --version > out.txt
R scripting front-end version 2.14.0 (2011-10-31)
C:\>dir out.txt
Volume in drive C has no label.
Volume Serial Number is 3568-1B07
Directory of C:\
07/18/2012 07:44 PM 0 out.txt
1 File(s) 0 bytes
0 Dir(s) 17,618,239,488 bytes free
有關爲什麼Rscript.exe輸出沒有被重定向到文件out.txt的任何想法或解釋?也許一個非常簡單的解釋等待。
感謝你,
不知道的重定向,但你可以使用'匯()'在R指令來完成你在找什麼。 – 2012-07-18 14:24:34
我猜數據正在寫入STDERR而不是STDOUT。嘗試將'2>&1'追加到命令中以將STDERR重定向到STDOUT,STDOUT然後將結束在outfile中。 – DaveRandom 2012-07-18 14:30:39
@JeffAllen謝謝傑夫。其實我正在通過嵌入上述命令的php腳本來檢查R版本。 – useR 2012-07-18 14:30:44