The R Project SVN R

Rev

Rev 37649 | Rev 40417 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2195 hornik 1
#!/bin/sh
2
#
4580 hornik 3
# ${R_HOME}/bin/BATCH
2195 hornik 4
 
37351 ripley 5
revision='$Rev: 40416 $'
7357 hornik 6
version=`set - ${revision}; echo ${2}`
11515 hornik 7
version="R batch front end ${version}
7217 hornik 8
 
37649 hornik 9
Copyright (C) 2000--2006 The R Core Development Team.
11515 hornik 10
This is free software; see the GNU General Public Licence version 2
11
or later for copying conditions.  There is NO warranty."
2195 hornik 12
 
31478 ripley 13
opts="--restore --save --no-readline"
27143 ripley 14
 
11515 hornik 15
usage="Usage: R CMD BATCH [options] infile [outfile]
16
 
7357 hornik 17
Run R non-interactively with input from infile and place output (stdout
18
and stderr) to another file.  If not given, the name of the output file
20002 hornik 19
is the one of the input file, with a possible '.R' extension stripped,
20
and '.Rout' appended.
7357 hornik 21
 
22
Options:
23
  -h, --help		print short help message and exit
24
  -v, --version		print version info and exit
25
  --			end processing of options
26
 
20002 hornik 27
Further arguments starting with a '-' are considered as options as long
28
as '--' was not encountered, and are passed on to the R process, which
27143 ripley 29
by default is started with '$opts'.
37649 hornik 30
See also help(BATCH) inside R.
7357 hornik 31
 
10633 hornik 32
Report bugs to <r-bugs@r-project.org>."
7357 hornik 33
 
2195 hornik 34
while test -n "${1}"; do
7217 hornik 35
  case ${1} in
7357 hornik 36
    -h|--help)
37
      echo "${usage}"; exit 0 ;;
38
    -v|--version)
39
      echo "${version}"; exit 0 ;;
7217 hornik 40
    --) shift; break ;;
7357 hornik 41
    -*) opts="${opts} ${1}"; shift ;;
7217 hornik 42
    *)  break ;;
43
  esac
2195 hornik 44
done
45
 
7357 hornik 46
in=${1}
47
out=${2-`basename ${1} .R`.Rout}
2195 hornik 48
 
40416 ripley 49
## this used to set options(echo=TRUE), but that is the default
50
## except for --slave, and why inhibit the latter?
51
(cat ${in}
35484 maechler 52
  echo ''; echo "proc.time()"
37649 hornik 53
) | ${R_HOME}/bin/R ${opts} ${R_BATCH_OPTIONS} >${out} 2>&1
7218 hornik 54
 
55
### Local Variables: ***
56
### mode: sh ***
57
### sh-indentation: 2 ***
58
### End: ***