[R] [newbie] scripting remote check for R package

Tom Roche Tom_Roche at pobox.com
Tue Sep 4 03:30:02 CEST 2012


https://stat.ethz.ch/pipermail/r-help/2012-September/322985.html
>>> for RSERVER in 'foo' 'bar' 'baz' ; do
>>>   ssh ${RSERVER} '<query R for package=package_name>'
>>> done

>>> or is there a better way to script checking for an R package?

https://stat.ethz.ch/pipermail/r-help/2012-September/323000.html
>> I would call something like this via ssh [...]

>> Rscript -e 'as.numeric(suppressWarnings(suppressPackageStartupMessages(require(ggplot2))))'

https://stat.ethz.ch/pipermail/r-help/2012-September/323024.html
> Thanks! but [the] cluster where I need to run this (where I do *not*
> have root) [lacks Rscript.] So I'm wondering:

> 1 Is there a way to do `Rscript -e` with plain, commandline R?

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:

> 2 What should my admin have done to install both Rscript and R?
>   (Alternatively, what should I tell my admin to do in order to make
>   both Rscript and R available?)

> 3 Is there any reason to install R without Rscript? (Alternatively,
>   when I ask my admin to install Rscript, is there any objection
>   I should anticipate?)

your assistance is appreciated, Tom Roche <Tom_Roche at pobox.com>




More information about the R-help mailing list