The R Project SVN R

Rev

Rev 42192 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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