1._Useful_scripts: 1. Useful scripts

Description RJobBatch.bat - A Windows command prompt scripts RJobBatch - A Unix shell scripts Author(s)

Description

Below are some useful scripts for command line processing.

RJobBatch.bat - A Windows command prompt scripts

Given that this script is in the PATH (or in the current directory), a job can be process by calling

RJobBatch --root=jobs-mandelbrot

from the command prompt.

The script can be found by

system.file("bin", "RJobBatch.bat", package="R.batch") and here is what it looks like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
echo off
rem ##################################################################
rem # RJobBatch
rem #
rem # Options: See help("main.JobBatch") for details.
rem #
rem # Windows script to run R one batch job utilizing R.batch.
rem #
rem # Author: Henrik Bengtsson, 2005-2012
rem ##################################################################

rem # Create R script to start JobBatch$main() in the R.batch package.
echo R.batch::JobBatch$main() > "%TEMP%\JobBatchMain.R"

rem # Start the R script and pass command line options
Rterm --vanilla --args %1 %2 %3 %4 %5 %6 %7 %8 %9 < "%TEMP%\JobBatchMain.R"

rem # Clean up
del "%TEMP%\JobBatchMain.R"

 

To add this automatically to the Windows search PATH, you can call the following in your Windows Command line startup script:

1
2
3
4
5
6
7
    Rterm --slave -e "cat(system.file('bin', package='R.batch'))" > %TEMP%\DIR.tmp
    for /F "delims=" %%G in (%TEMP%\DIR.tmp) do set dir=%%~sG
    IF EXIST "%dir%" (
      echo Detected R.batch package - added to the search path.
      path %PATH%;%dir%
    )
  

RJobBatch - A Unix shell scripts

Given that this script is in the PATH (or in the current directory), and has execute rights, a job can be process by calling

RJobBatch --root=jobs-mandelbrot

from the command prompt.

The script can be found by

system.file("bin", "RJobBatch", package="R.batch") and here is what it looks like:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
#!/usr/bin/env sh
##################################################################
# RJobBatch
#
# Options: See help("main.JobBatch") for details.
#
# Shell script to run R one batch job utilizing R.batch.
#
# Author: Henrik Bengtsson, 2005-2012
##################################################################

# Create R script to start JobBatch$main() in the R.batch package.
echo 'R.batch::JobBatch$main()' > /tmp/JobBatchMain.R

# Start the R script and pass command line options
R --vanilla --args $* < /tmp/JobBatchMain.R

# Clean up
rm /tmp/JobBatchMain.R

 

To add this automatically to the Unix search PATH, you can call the following in your shell startup script:

1
2
3
4
5
6
    dir=`R --slave -e "cat(system.file('bin', package='R.batch'))"`
    if test -d "${dir}" (
      echo Detected R.batch package - added to the search path.
      setenv PATH=${PATH};${dir}
    )
  

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)


R.batch documentation built on May 2, 2019, 4:58 p.m.