【发布时间】:2012-07-18 14:20:04
【问题描述】:
考虑两种情况 a) 关闭输出重定向和 b)Rscript 输出重定向到文件 out.txt 两种情况下在 STDOUT 中看到的输出都无法重定向到文件 out.txt 仅在场景 b 中。我在这里遗漏了什么还是 Rscript.exe 特有的?
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 中的
sink()命令来完成您要查找的内容。 -
我猜数据正在写入 STDERR 而不是 STDOUT。尝试将
2>&1附加到将 STDERR 重定向到 STDOUT 的命令中,然后将在输出文件中结束。 -
@JeffAllen 谢谢杰夫。实际上,我希望通过嵌入上述命令来检查 R 版本的 php 脚本来执行此操作。
-
@DaveRandom 谢谢戴夫。输出被写入 STDERR 并且 2>&1 占了它。
标签: php r dos stdout io-redirection