[R] Using csh

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Mar 1 15:18:39 CET 2001


> Date: Thu, 01 Mar 2001 14:30:32 +0100
> To: R Help list <r-help at stat.math.ethz.ch>
> From: Christian Hoffmann <christian.hoffmann at wsl.ch>
> Subject: [R] Using csh
> 
> Hi all,
> 
> I am fancying the idea of using my preferred shell (t)csh when invoking
> system(). How can I do that? (I didn't find anything about that in the FAQ).
> 

It's not an R issue.  On Unix/Linux (I am presuming), R's system calls
calls the C calls system or popen.  What shell system(3) calls is OS-specific,
and in the case of Solaris, argument-specific too.

Also, system() is used a lot by R itself, so you don't want to risk
breaking that.

Here is a workaround: you need to do it this way to avoid quoting issues.

shell <- function(command, shell="tcsh", ...)
{
   input <- tempfile("in")
   on.exit(unlink(input))
   cat(command, "\n", sep="", file=input)
   system(paste(shell, input), ...)
}

The Windows version has a shell() command: is there enough need for
something like this on Unix?   (The granddaddy is unix.shell(),
I think from S3.)

-- 
Brian D. Ripley,                  ripley at 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-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list