The R Project SVN R

Rev

Rev 7218 | Rev 8783 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7218 Rev 7357
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# ${R_HOME}/bin/BATCH
3
# ${R_HOME}/bin/BATCH
4
 
4
 
5
REVISION='$Revision: 1.6 $'
5
revision='$Revision: 1.7 $'
6
VERSION=`set - ${REVISION}; echo ${2}`
6
version=`set - ${revision}; echo ${2}`
7
USAGE_MSG="Usage: R BATCH [options] infile [outfile]"
7
version="R batch front end ${version}"
8
 
8
 
-
 
9
usage="Usage: R BATCH [options] infile [outfile]
-
 
10
 
-
 
11
Run R non-interactively with input from infile and place output (stdout
-
 
12
and stderr) to another file.  If not given, the name of the output file
-
 
13
is the one of the input file, with a possible \`.R' extension stripped,
-
 
14
and \`.Rout' appended.
-
 
15
 
-
 
16
Options:
-
 
17
  -h, --help		print short help message and exit
-
 
18
  -v, --version		print version info and exit
-
 
19
  --			end processing of options
-
 
20
 
-
 
21
Further arguments starting with a \`-' are considered as options as long
-
 
22
as \`--' was not encountered, and are passed on to the R process, which
-
 
23
by default is started with \`--restore --save --no-readline'.
-
 
24
 
-
 
25
Report bugs to <R-bugs@lists.r-project.org>."
-
 
26
 
9
OPTS="--restore --save --no-readline"
27
opts="--restore --save --no-readline"
10
 
28
 
11
while test -n "${1}"; do
29
while test -n "${1}"; do
12
  case ${1} in
30
  case ${1} in
13
    -h|--help|-\?)
31
    -h|--help)
14
      echo "${USAGE_MSG}"; exit 0 ;;
32
      echo "${usage}"; exit 0 ;;
15
    -V|--version)
33
    -v|--version)
16
      echo "${VERSION}"; exit 0 ;;
34
      echo "${version}"; exit 0 ;;
-
 
35
    --vsize|--nsize)
-
 
36
      # Deprecated ...
-
 
37
      opts="${opts} ${1}=${2}"; shift 2 ;;
17
    --) shift; break ;;
38
    --) shift; break ;;
18
    --vsize|--nsize|-v|-n)
-
 
19
      OPTS="${OPTS} ${1} ${2}"; shift 2 ;;
-
 
20
    -*) OPTS="${OPTS} ${1}"; shift ;;
39
    -*) opts="${opts} ${1}"; shift ;;
21
    *)  break ;;
40
    *)  break ;;
22
  esac
41
  esac
23
done
42
done
24
 
43
 
25
IN=${1}
44
in=${1}
26
OUT=${2-`basename ${1} .R`.Rout}
45
out=${2-`basename ${1} .R`.Rout}
27
 
46
 
28
(echo "invisible(options(echo = TRUE))"
47
(echo "invisible(options(echo = TRUE))"
29
 cat ${IN}
48
  cat ${in}
30
 echo "proc.time()"
49
  echo "proc.time()"
31
) | ${R_HOME}/bin/R ${OPTS} >${OUT} 2>&1
50
) | ${R_HOME}/bin/R ${opts} >${out} 2>&1
32
 
51
 
33
### Local Variables: ***
52
### Local Variables: ***
34
### mode: sh ***
53
### mode: sh ***
35
### sh-indentation: 2 ***
54
### sh-indentation: 2 ***
36
### End: ***
55
### End: ***