3

According to the manual, the stdout argument of the system2 function can redirect output to a file. This seems to work on unix, however I can't get it to work on windows. The toy example below, no out.txt or err.txt files are created. I tried sending it to an existing file, or expand the full file path, but with no success:

setwd(tempdir())
system2("whoami", stdout="out.txt", stderr="err.txt")
file.exists("out.txt")

Am I doing something wrong or is this a limitation in system2 ?

Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207
  • Your snippet shows `system()`, not `system2()`. Typo? – Dirk Eddelbuettel Jul 14 '13 at 09:47
  • Good question. `system2` doesn't seem to be behaving as advertised. Especially given that the Windows and UNIX versions of `system2` are implemented using different source code, you'd think this difference in behavior (if intended) would be mentioned in `?system2`. – Josh O'Brien Jul 14 '13 at 17:33
  • OK in that case I'll move it to `r-devel`. – Jeroen Ooms Jul 14 '13 at 18:14
  • Thanks. [Uwe Ligges here mentions](https://stat.ethz.ch/pipermail/r-help/2010-November/258381.html) that portability was the motivation for creating `system2()`, so this is presumably a discrepancy R-core will care about. (FWIW, I just tried Grothendieck's proposed fix (from R-devel), and it doesn't work for me, running an up-to-date R on Windows XP...) – Josh O'Brien Jul 14 '13 at 21:11

1 Answers1

1

I'm quite convinced now this is a bug in RGui.exe in windows. I filed a bug report here: https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15393

Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207
  • Thanks for your answer. Had [the same issue](http://stackoverflow.com/q/18080378/684229). – Tomas Aug 06 '13 at 12:55