Skip to content
Prev 304754 / 398506 Next

[newbie] scripting remote check for R package

https://stat.ethz.ch/pipermail/r-help/2012-September/322985.html
https://stat.ethz.ch/pipermail/r-help/2012-September/323000.html
https://stat.ethz.ch/pipermail/r-help/2012-September/323024.html
I learned how to use `R CMD BATCH`. It's definitely more painful than
`Rscript -e`, but at least the following works:

EXEC_DIR='/share/linux86_64/bin' # on foo, at least
# EXEC_NAME='Rscript'
EXEC_NAME='R'
EXEC_PATH="${EXEC_DIR}/${EXEC_NAME}"
BATCH_INPUT_PATH="./junk.r"      # presumably in home dir
BATCH_OUTPUT_PATH="./junk.r.out" # ditto
for RSERVER in 'foo' 'bar' 'baz' ; do
  echo -e "${RSERVER}:"
# The following 3 commands attempted to debug a
# separate but related problem; about which, see
# http://serverfault.com/questions/424027/ssh-foo-command-not-loading-remote-aliases
#  ssh ${RSERVER} "${EXEC_NAME} --version | head -n 1"
#  ssh ${RSERVER} "grep -nHe 'bashrc' ~/.bash_profile"
#  ssh ${RSERVER} "grep -nHe '\W${EXEC_NAME}\W' ~/.bashrc"
  ssh ${RSERVER} "${EXEC_PATH} --version | head -n 1"
  ssh ${RSERVER} "echo -e 'as.numeric(suppressWarnings(suppressPackageStartupMessages(require(M3))))\n' > ${BATCH_INPUT_PATH}"
  ssh ${RSERVER} "rm ${BATCH_OUTPUT_PATH}"
  ssh ${RSERVER} "ls -al ${BATCH_INPUT_PATH}"
  ssh ${RSERVER} "cat ${BATCH_INPUT_PATH}"
  ssh ${RSERVER} "${EXEC_PATH} CMD BATCH --slave --no-timing ${BATCH_INPUT_PATH} ${BATCH_OUTPUT_PATH}"
  ssh ${RSERVER} "ls -al ${BATCH_OUTPUT_PATH}"
  ssh ${RSERVER} "head -n 1 ${BATCH_OUTPUT_PATH}"
  echo # newline
done

Given the pain, I'd still like to know:
your assistance is appreciated, Tom Roche <Tom_Roche at pobox.com>