Bash script – “Rscript: command not found” error

bashlinuxr

I have the following bash script trying to run it in Linux but I receive an error message that line 31: Rscript: command not found. Can you please give me an advice if where I am wrong?

#!/bin/bash
#PBS -S /bin/bash
#PBS -N garunsmodel
#PBS -l mem=10g
#PBS -l walltime=02:00:00
#PBS -A improvingherds
#PBS -m ae


nodeDir=`mktemp -d /tmp/phuong.XXXXX`

cp -r /group/dairy/phuongho/garuns $nodeDir

cd $nodeDir

cd garuns
module load gcc vle // this is to load vle platform
rm -rf out
mkdir out

#In garuns.vpz. The output file path has to be changed.
#to an absolute path that's available on the node the script is running.

XXX=`pwd`
sed -i "s|/group/dairy/phuongho/garuns/out|$XXX/out/|" exp/garuns.vpz
Rscript  R/repetability.R

DATE=`date +%Y%m%d-%H%M%S`
mkdir "/group/dairy/phuongho/job.$DATE"

cp -r out  "/group/dairy/phuongho/job.$DATE"

When I tried to access manually to tmp/phuong.XXXXX/garuns then run R, it worked just fine.

Best Answer

If R has already been installed, it could be that the PATH variable picks up the wrong RScript? Check with which RScript

In this case try export PATH=/path/to/alternate/r/bin:$PATH Or try brute-forcing by giving the absolute path when referencing RScript, e.g. ~/R-3.2.5_patched/bin/RScript/R/repetability.R

Related Question