summary: e.g., how to replace '<query R for package=package_name>' in the following: 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? details: For my work I need a few non-standard R packages. I do that work on 2 clusters. One uses environment modules, so any given server on that cluster can provide (via `module add`) pretty much the same resources. The other cluster, on which I must also unfortunately work, has servers managed individually, so I get in the habit of doing, e.g., EXEC_NAME='whatever' for S in 'foo' 'bar' 'baz' ; do ssh ${RSERVER} "${EXEC_NAME} --version" done periodically. I'm wondering, what incantation to utter (bash preferred) via ssh to query a given server's R for a given package? TIA, Tom Roche <Tom_Roche at pobox.com>
I would call something like this via ssh (please note: I used "ggplot2" in the example): Rscript -e 'as.numeric(suppressWarnings(suppressPackageStartupMessages(require(ggplot2))))' You could easily extend this to loop through the required packages and tweak the output for your needs. Best, Gergely On Sun, Sep 2, 2012 at 10:42 PM, Tom Roche <Tom_Roche@pobox.com> wrote:> > summary: e.g., how to replace '<query R for package=package_name>' > in the following: > > 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? > > details: > > For my work I need a few non-standard R packages. I do that work on 2 > clusters. One uses environment modules, so any given server on that > cluster can provide (via `module add`) pretty much the same resources. > > The other cluster, on which I must also unfortunately work, has > servers managed individually, so I get in the habit of doing, e.g., > > EXEC_NAME='whatever' > for S in 'foo' 'bar' 'baz' ; do > ssh ${RSERVER} "${EXEC_NAME} --version" > done > > periodically. I'm wondering, what incantation to utter (bash preferred) > via ssh to query a given server's R for a given package? > > TIA, Tom Roche <Tom_Roche@pobox.com> > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
https://stat.ethz.ch/pipermail/r-help/2012-September/322985.html>> e.g., how to replace '<query R for package=package_name>' in the >> following:>> 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))))'Thanks! but ... While that works great on _my_ linux boxes (on which I installed R), on the cluster where I need to run this (where I do *not* have root) me at foo:~ $ which Rscript> /usr/bin/which: no Rscript in (/home/me/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin)me at foo:~ $ find /share -name 'Rscript' | wc -l> 0me at foo:~ $ which R> alias R='/share/linux86_64/bin/R' > /share/linux86_64/bin/RSo I'm wondering: 1 Is there a way to do `Rscript -e` with plain, commandline R? 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?) thanks again, Tom Roche <Tom_Roche at pobox.com>
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>
https://stat.ethz.ch/pipermail/r-help/2012-September/322985.html>>> [how] to script [remote] 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?Incorporating Gergely Dar?czi's last suggestion (k?sz?n?m!) I get # the package for which to check that has the most dependencies APEX_PKG='M3' # substitute yours for RSERVER in 'foo' 'bar' 'baz' ; do echo -e "${RSERVER} has:" ssh ${RSERVER} "R --version | head -n 1" ssh ${RSERVER} "echo -e ${RSERVER} has ${APEX_PKG}:" ssh ${RSERVER} "R --slave -e 'as.logical(suppressWarnings(suppressPackageStartupMessages(require(${APEX_PKG}))))'" echo # newline done which works. 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>
As described in the thread beginning @ https://stat.ethz.ch/pipermail/r-help/2012-September/322985.html I work (as a user, without root) on a cluster that has several servers on which R is installed but not Rscript. I'd like to know 1 What should I tell my admin to do in order to make both Rscript and R available? (FWIW I believe the boxes are running CentOS, though possibly RHEL 5 or 6.) 2 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? TIA, Tom Roche <Tom_Roche at pobox.com>