考虑以下两种情况: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