Rev 47259 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/base/man/windows/shell.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2008 R Core Development Team% Distributed under GPL 2 or later\name{shell}\Rdversion{1.1}\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 \sQuote{Details}.}\item{flag}{the switch to run a command under the shell. If the shellis \code{bash} or \code{tcsh} or \code{sh} 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}, \samp{"/"} in \code{cmd} istranslated to \samp{"\\"}.}\item{mustWork}{a logical; if \code{TRUE} failure to run the commandwill give an \R error, if \code{FALSE} a warning and if \code{NA},no \R message.}\item{\dots}{additional arguments to \code{\link{system}}.}}\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 an error code, given theinvisible attribute (so needs to be printed explicitly). 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\env{R_SHELL}, \env{SHELL} and \env{COMSPEC} are tried in turn:\env{COMSPEC} should always succeed. Using \code{shell = NULL}invokes the command \code{cmd} directly, in which case an extensionof \file{.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}. To make use of Windowsfile associations, use \code{\link{shell.exec}}.}\seealso{\code{\link{system}}, \code{\link{shell.exec}}}\keyword{utilities}