From ripley@stats.ox.ac.uk  Fri May 19 22:46:09 2000
From: ripley@stats.ox.ac.uk (Prof Brian D Ripley)
Date: Fri, 19 May 2000 22:46:09 +0100 (BST)
Subject: [Rd] system(.., ignore.stderr = TRUE)  problem on Solaris (PR#547)
In-Reply-To: <200005191911.VAA02042@pubhealth.ku.dk>
Message-ID: <Pine.GSO.4.05.10005192223470.4118-100000@auk.stats>

On Fri, 19 May 2000 maechler@stat.math.ethz.ch wrote:

> (i.e. my version Solaris, see below...)
> 
> Note that system() is not only implemented quite system-dependently
> (which you'd very much expect!) but also Unix and Windows have quite
> different arguments apart from the first two.
> 
> Hence all the following is ``Unix-only'' :
> 
> 
> A user stumbled across this when using read.table.url(.) on a platform
> where no "wget" is installed: 
> 
> The data is read ok, but an ugly message appears *before* the command is
> completed :
> 	  -------------------
> 	  sh: wget: not found
> 	  -------------------
> which made the user believe that the data wasn't read properly.
> 
> The problem is easily tracked to the system(..) call in download.file()
> {which does not (yet) have the "ignore.stderr = TRUE" setting, btw}
> and found that on our Solaris environment, 
> the ignore.stderr argument does not seem to have any effect, i.e.
> 
>   > system("bla", ignore.stderr = TRUE)
> 
> gives the same as  system("bla"), namely
>   
>   sh: bla: not found

Under sh you cannot redirect the output from a command until the command
is running.  That is, you are not redirecting the error messages from sh,
only from the command.  Unless the command runs, ignore.stderr has no
effect.

> On my Linux environment,  ignore.stderr works as advertized.

Depends how you read the advertising.

> Further note that  help(system)  should probably also say something about which
> shell may or may not be used (I think we decided that we want it to be `sh'
> on Unix).

Yes, and you almost certainly got bash *not* sh on your Linux, and that
behaves differently.  I think you will find that a closer sh clone (such as
ash) does show the error message.  That some Linux systems claim to have sh
and do not is a major compatibility problem in writing shell scripts and
Makefiles, as we keep finding.

BTW, Solaris will use ksh not sh for the shell if it needs to be POSIX
compatible. And ksh behaves like bash in this respect.


I believe that to define this portably we are going to have to do something
a lot more complicated than accept what the system() call gives us. Are you
volunteering, Martin?


-- 
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(.., ignore.stderr = TRUE) problem on Solaris (PR#547)
Prof Brian D Ripley