From ripley@stats.ox.ac.uk  Fri Feb  9 14:28:58 2001
From: ripley@stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 9 Feb 2001 14:28:58 +0000 (GMT)
Subject: [Rd] system command
In-Reply-To: <3A83EE88.67F639ED@univie.ac.at>
Message-ID: <Pine.GSO.4.31.0102091415080.18117-100000@toucan.stats>

On Fri, 9 Feb 2001, Erich Neuwirth wrote:

> i am using
> system
> to call the external program csound.
> csound does some output to stdout and some to stderr
> system handles this differently on the different platforms.
>
> on unix (i have solaris, but as far as i know it is the same on linux)
> system("csound",intern=TRUE) redirects stdin into an R object,
> by still outputs stdout to the R window.

I *think* you mean redirect stdout, and sends stderr to the terminal
running R.

> system("csound",intern=FALSE) (equivalent to system("csound"))
> stdout and stderr go into the R window
>
> Rterm
> on win95
> system("csound",intern=TRUE) redirects stdin and stderr into an R object

Redirects stdout and stderr to the terminal running R?

> system("csound",intern=FALSE) (equivalent to system("csound"))
> outputs everything
>
> Rterm
> on win2k
> system("csound",intern=TRUE) redirects stdin and stderr into an R object
> system("csound",intern=FALSE) (equivalent to system("csound"))
> outputs everything
> EXCEPT
> once
> system("csound",intern=TRUE) has been done
> and later one tries
> system("csound",intern=FALSE)
> stderr is lost completely.
> going back to
> system("csound",intern=TRUE)
> redirects stderr again into the R object,
> but stderr does not go to the screen any more
> after intern=TRUE has been used once.
>
>
> so we seem to have to problems:
> 1) different behavior of system on unix and win32k

They are documented to be different!  Whether stdout and stderr are
different is OS-specific.  In particular, Windows consoles have no concept
of stdout.

> 2) problems with system and redirection on win32k.

A bug, almost certainly in Windows 2000 since this works as documented
under NT.   Guido?

But, the essence is that you cannot reasonably expect to use stderr from
a program run by a system() commands, and that applies to, say, Perl
as much as to R.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] system command
Prof Brian Ripley