[R] capturing stdout

Sarah Goslee sarah.goslee at gmail.com
Wed Dec 30 21:24:57 CET 2009


Nick,

You don't specify OS, so details might differ, but on my linux system the
help for system (which should be the first place you'd look anyway) has
an entire section on stdout and stderr

Stdout and stderr:

     Error messages written to ‘stderr’ will be sent by the shell to
     the terminal unless ‘ignore.stderr = TRUE’.  They can be captured
     (in the most likely shells) by


         system("some command 2>&1", intern=TRUE)

     What happens to output sent to ‘stdout’ and ‘stderr’ if ‘intern =
     FALSE’ is interface-specific, and it is unsafe to assume that such
     messages will appear on a console (they do on the Mac OS X
     console, but not on some others).

Sarah

On Wed, Dec 30, 2009 at 3:15 PM, Nick Torenvliet
<nick.torenvliet at gmail.com> wrote:
> I'm wondering if anyone knows of a way to capture system messages, for
> instance when I do the following:
>
>> system("../DBScripts/getEODData.sh")
> .//LSE_20091230.txt:                                   154.80 kB  207.24
> kB/s
> ./Fundamentals//LSE.txt:                               420.58 kB  301.47
> kB/s
> ./Fundamentals//MLSE.txt:                                3.42 kB   16.20
> kB/s
> Remote host has closed the connection.
> ncftpget /: remote host closed control connection.
>>
>
> I'd like to get the stdout from the system call into some memory location
> where I can play with it...
>
> Is there a simple way to do this?
>


-- 
Sarah Goslee
http://www.functionaldiversity.org




More information about the R-help mailing list