Mercurial > repos > matces > carpet_toolsuite
annotate carpet-src-1/tools/CARPET/r_wrapper2.sh @ 0:cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author | matces |
---|---|
date | Tue, 07 Jun 2011 16:50:41 -0400 |
parents | |
children |
rev | line source |
---|---|
0
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
1 #!/bin/sh |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
2 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
3 ### Run R providing the R script in $1 as standard input and passing |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
4 ### the remaining arguments on the command line |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
5 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
6 # Function that writes a message to stderr and exits |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
7 function fail |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
8 { |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
9 echo "$@" >&2 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
10 exit 1 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
11 } |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
12 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
13 # Ensure R executable is found |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
14 which R > /dev/null || fail "'R' is required by this tool but was not found on path" |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
15 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
16 # Extract first argument |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
17 infile=$1; shift |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
18 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
19 # Ensure the file exists |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
20 test -f $infile || fail "R input file '$infile' does not exist" |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
21 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
22 # Invoke R passing file named by first argument to stdin |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
23 cat $infile > /tmp/sticazzi.R |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
24 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
25 R --vanilla --slave -f $infile $* 2> /dev/null |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
26 |
cdd489d98766
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
matces
parents:
diff
changeset
|
27 |