[Rd] Problem with system2(), directing STDERR to a file

From: Dan Tenenbaum <dtenenba_at_fhcrc.org>
Date: Wed, 10 Nov 2010 18:21:21 -0800


According to ?system2, I should be able to direct the output of STDERR to a file by giving the filename as a character vector to the "stderr" argument.

But here is what happens.

Given a ruby script test.rb (with its executable bit set):

#!/usr/bin/env ruby
STDOUT.puts "stdout"
STDERR.puts "stderr"

And the following R code:

> t <- tempfile()
> res <- system2("./test.rb", stdout=TRUE, stderr=t)
stderr
> res

[1] "stdout"
> file.exists(t)

[1] FALSE I would expect the file t to exist and contain "stderr", and I would expect not to see "stderr" in the console.

Also, there is a typo in the man page - the command is listed as "system" in the Description instead of "system2".

The reverse behavior does work correctly:
> res <- system2("./test.rb", stdout=t, stderr="")
stderr
> file.exists(t)

[1] TRUE Thanks!
Dan

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 11 Nov 2010 - 02:23:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 11 Nov 2010 - 05:20:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive