\HeaderA{Rscript}{Scripting Front-End for R}{Rscript}
\keyword{utilities}{Rscript}
\begin{Description}\relax
This is an alternative front end for use in \code{\#!} scripts and
other scripting applications.
\end{Description}
\begin{Usage}
\begin{verbatim}
Rscript [options] [-e expression] file [args]
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{options}] A list of options beginning with \code{--}.  These can
be any of the options of the standard \R{} front-end, and also those
described in the details.
\item[\code{expression}] a \R{} expression.
\item[\code{file}] The name of a file containing \R{} commands.  \code{-}
indicates \file{stdin}.
\item[\code{args}] Arguments to be passed to the script in \code{file}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{Rscript --help} gives details of usage, and \code{Rscript
    --version} gives the version of \code{Rscript}.

Other invocations invoke the \R{} front-end with selected options.  This
front-end is convenient for writing \code{\#!} scripts since it is an
executable and takes \code{file} directly as an argument.  Options
\code{--slave --no-restore} are always supplied: these imply
\code{--no-save}.

\emph{Either} one or more \option{-e} options or \code{file} should
be supplied.

Additional options accepted (before \code{file} or \code{args}) are
\describe{
\item[\code{--verbose}] gives details of what \code{Rscript} is
doing.  Also passed on to \R.
\item[\code{--default-packages=list}] where \code{list} is a
comma-separated list of package names or \code{NULL}.  Sets the
environment variable \env{R\_DEFAULT\_PACKAGES} which determines the
packages loaded on startup.  The default for \code{Rscript} omits
\pkg{methods} as it takes about 60\% of the startup time.

}

Normally the version of \R{} is determined at installation, but this can
be overridden by setting the environment variable \env{RHOME}.

\code{\LinkA{stdin}{stdin}()} refers to the input file, and
\code{\LinkA{file}{file}("stdin")} to the \code{stdin} file stream of the
process.
\end{Details}
\begin{Note}\relax
\code{Rscript} is only supported on systems with the \code{execv}
system call.
\end{Note}
\begin{Examples}
\begin{ExampleCode}## Not run: 
Rscript -e 'date()' -e 'format(Sys.time(), "%a %b %d %X %Y")'

## example #! script

#! /path/to/Rscript --vanilla --default-packages=utils
args <- commandArgs(TRUE)
res <- try(install.packages(args))
if(inherits(res, "try-error")) q(status=1) else q()

## End(Not run)\end{ExampleCode}
\end{Examples}

