1#!/bin/tcsh -f 2set pp = $0:h 3#Run R in script more. Better than R CMD BATCH 4if ($#argv) then 5 set na = $#argv; if ($na>10) set na=10; 6 @global_parse `basename $0` "$argv[1-$na]" ; if ($status) exit 0 ; 7endif 8 9if ($#argv == 0) then 10 set arglist = (-help) 11else 12 set noglob 13 set arglist = ($*) 14 unset nogolb 15endif 16 17set tname = `basename $0`.R 18set afpath = `which afni` 19set afpath = `dirname $afpath` 20if ( -f $pp/${tname}) then 21 set tname = $pp/${tname} 22else if ( -f $pp/R_scripts/${tname}) then 23 set tname = $pp/R_scripts/${tname} 24else if ( -f $afpath/${tname}) then 25 set tname = $afpath/${tname} 26else 27 echo "** Error `basename $0`:" 28 echo "${tname} not found in $pp or $pp/R_scripts or $afpath" 29 echo "" 30endif 31 32# for macos: search abin and flat_namespace for shared objects 33if ( -d /opt/X11/lib/flat_namespace ) then 34 echo updating R_LD_LIBRARY_PATH ... 35 setenv R_LD_LIBRARY_PATH `R RHOME`/lib:${afpath}:/opt/X11/lib/flat_namespace 36endif 37 38 39if (0) then 40 #This worked OK, except for the blasted -gSOMETHING problem 41 Rscript ${tname} $arglist 42else 43 #command taken from Rscript --verbose ... 44 #by adding the --gui option explicitly here, I can 45 #quiet the stupid message: WARNING: unknown gui ... 46 #every time there is a -gSOMETHING option in arglist 47 R --slave --no-restore --file=${tname} --gui X11 --args $arglist 48endif 49