Rev 6179 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{shell}\alias{shell}\title{Invoke a System Command, using a Shell}\usage{shell(cmd, shell, flag="/c", intern=FALSE, wait=TRUE,translate=FALSE, mustWork=FALSE)}\arguments{\item{cmd}{the system command to be invoked, as a string.}\item{shell}{a string giving the name of the shell to be used, or\code{NULL} (no shell). If missing, a suitable shell is chosen:see `details'}\item{flag}{the switch to run a command under the shell. If theshell is \code{bash} or \code{tcsh} the default is changed to\code{"-c"}.}\item{intern}{a logical, indicates whether to make the output of thecommand an \R object.}\item{wait}{should the \R interpreter wait for the command to finish?The default is to wait, and the interpreter will always wait if\code{intern = TRUE}.}\item{translate}{If \code{TRUE}, \code{"/"} in \code{cmd} istranslated to \code{"\\"}.}\item{mustWork}{a logical; if \code{TRUE} failure to run the commandwill give an \R error.}}\description{\code{shell} runs the command specified by \code{cmd}, usually undera shell.}\value{If \code{intern=TRUE}, a character vector giving the output of thecommand, one line per character string, or an error message if thecommand could not be run.If \code{intern=FALSE}, the return value is a error code, given theinvisible attribute (so needs to be printed explictly). If thecommand could not be run for any reason, the value is \code{-1} andan \R warning is generated. Otherwise if \code{wait=FALSE} the valueis the error code returned by the command, and if \code{wait=TRUE}it is the zero (the conventional success value),If \code{intern=FALSE} and \code{wait=TRUE} (the defaults) the textoutput from a command that is a console application will appear inthe \R console (\code{Rgui}) or the window running \R (\code{Rterm}).}\details{If no \code{shell} is specified, the environment variables\code{R\_SHELL}, \code{SHELL} and \code{COMSPEC} are tried in turn:\code{COMSPEC} should always succeed. Using \code{shell=NULL}invokes the command \code{cmd} directly, in which case an extensionof \code{.exe} is assumed. It is possible to use batch filesdirectly if their extension is given: Windows (rather than \R) thenchooses a shell.See \code{\link{system}} for fuller details: \code{shell} is a moreuser-friendly wrapper for \code{system}.}\author{B. D. Ripley}\seealso{\code{\link{system}}}\keyword{utilities}