加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

R:使用system()调用的别名命令

发布时间:2020-12-15 22:57:54 所属栏目:安全 来源:网络整理
导读:在我的?/ .bash_profile文件中,我放了这个别名命令: which mvsyncalias mvsync='rsync --remove-source-files -arvuP' /usr/bin/rsync 它可以从bash shell中正常工作,但是当我从系统内部R调用它时,我得到一个未找到的命令: Rsystem('mvsync --help')sh: mv
在我的?/ .bash_profile文件中,我放了这个别名命令:

which mvsync
alias mvsync='rsync --remove-source-files -arvuP'
    /usr/bin/rsync

它可以从bash shell中正常工作,但是当我从系统内部R调用它时,我得到一个未找到的命令:

R
system('mvsync --help')
sh: mvsync: command not found

## Or
system('mvsync --help',intern=TRUE)
sh: mvsync: command not found
Error in system("mvsync --help",intern = TRUE) : 
  error in running command

## Or
system("bash -i -c mvsync")
bash: mvsync: command not found

[4]+  Stopped                 R

R / system()可以正确识别bash_profile中的其他环境变量.
知道如何/如果它可以修复?

这是R会话信息:

sessionInfo()
R version 3.1.3 (2015-03-09)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS release 6.6 (Final)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] graphics  grDevices utils     datasets  stats     methods   base     

other attached packages:
[1] ggplot2_1.0.0    data.table_1.9.4

loaded via a namespace (and not attached):
 [1] chron_2.3-45     colorspace_1.2-4 digest_0.6.8     grid_3.1.3       gtable_0.1.2     MASS_7.3-39      munsell_0.4.2    plyr_1.8.1       proto_0.3-10     Rcpp_0.11.3      reshape2_1.4     scales_0.2.4     stringr_0.6.2

解决方法

您的shell可能不是登录shell: http://linux.die.net/man/1/bash

When bash is invoked as an interactive login shell,or as a non-interactive shell with the –login option,it first reads and executes commands from the file /etc/profile,if that file exists. After reading that file,it looks for ~/.bash_profile,~/.bash_login,and ~/.profile,in that order,and reads and executes commands from the first one that exists and is readable. The –noprofile option may be used when the shell is started to inhibit this behavior.

–login可能有效,但最好将你的别名放在.bashrc中,即使它不是登录shell也会被执行

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读