【发布时间】:2015-05-03 12:46:50
【问题描述】:
我在远程主机上提交了一个 shell 脚本,该脚本又提交了一个 R 脚本,但是错误 R: command not found 或 Rscript: command not found(取决于我是否尝试了 R CMD BATCH 或 Rscript)。
我尝试过以下几种方式提交:
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 BATCH 或Rscript 的解决方案,但如果有使用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 ..