【问题标题】:R Command not recognized when submitted with SSH使用 SSH 提交时无法识别 R 命令
【发布时间】:2015-05-03 12:46:50
【问题描述】:

我在远程主机上提交了一个 shell 脚本,该脚本又提交了一个 R 脚本,但是错误 R: command not foundRscript: command not found(取决于我是否尝试了 R CMD BATCHRscript)。

我尝试过以下几种方式提交:

 ssh <remote-host> exec $HOME/test_script.sh

 ssh <remote-host> `sh $HOME/test_script.sh`

脚本test_script.sh 包含(也尝试过Rscript):

#!/bin/sh

Rscript --no-save --no-restore $HOME/greetme.R

exit 0

脚本greetme.R 仅包含cat("Hello\n")

我心慌的原因是当我登录remote-host并使用sh $HOME/test_script.sh提交原始脚本时,它按预期运行。

本地和远程主机的系统规格和 R 版本相同:

> R.version
               _                           
platform       x86_64-unknown-linux-gnu    
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          3                           
minor          1.0                         
year           2014                        
month          04                          
day            10                          
svn rev        65387                       
language       R                           
version.string R version 3.1.0 (2014-04-10)
nickname       Spring Dance       

为什么 Linux 拒绝识别命令?

我更喜欢使用R CMD BATCHRscript 的解决方案,但如果有使用littler%R_TERM% 的已知解决方法,我也想听听。

我用这个相关的问题作为参考,以及cmets中引用的文档:R.exe, Rcmd.exe, Rscript.exe and Rterm.exe: what's the difference?

编辑解决方案:

正如@merlin2011 所建议的,一旦我在test_script.sh 中指定了完整路径,一切都会按预期进行:

#!/bin/sh

/opt/R/bin/Rscript --no-save --no-restore $HOME/greetme.R

exit 0

我也通过提供的建议得到了路径:

$ which Rscript
/opt/R/bin/Rscript

【问题讨论】:

  • 你试过R --slave -f script.R --args arg1 arg2 ..

标签: linux r ssh


【解决方案1】:

您似乎遇到了PATH 问题,当您尝试通过ssh 运行命令时,R 不在您的PATH 上。

如果您在远程主机上指定RRscript 的完整路径,应该可以解决问题。

如果您不确定完整路径是什么,请尝试登录服务器并运行which R 以获取路径。

【讨论】:

    猜你喜欢
    • 2011-10-25
    • 1970-01-01
    • 2016-09-12
    • 2021-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-15
    • 2020-09-25
    相关资源
    最近更新 更多