R 系统函数总是返回错误 127 [英] R system functions always returns error 127

查看:30
本文介绍了R 系统函数总是返回错误 127的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 R 执行外部工具并处理该工具中发生的错误(如果有).我知道 3 个函数可以完成我的任务:

I need to execute an external tool from R and process errors (if any) occurred in that tool. I know 3 functions to do something familiar with my task:

shell, system and system2.

尝试测试这些,我看到了那个命令

Trying to test those, I see that command

shell("notepad") 

打开记事本.据我所知,shell 不允许检查错误(没有界面可以查看 stderr).

opens notepad. As far as I know shell doesn't allow to check errors (there's no interface to look into stderr).

当我打电话时

system("notepad")

system2("notepad") 

R 在尝试执行这些命令时冻结.

R freezes trying to make those commands.

打电话

system("start notepad") 

system2("start notepad") 

返回警告

Warning message:
running command '"start notepad"' had status 127 

推荐答案

正如我在评论中提到的,R 文档显示在 Windows 中,system() 函数不会启动单独的 shell(如果需要的话).这就是为什么命令行命令使用 system() 运行,但需要单独窗口的记事本不运行:

As I mentioned in my comments, the R documentation reveals that in Windows the system() function does not launch a separate shell (if needed). This is why command line commands run with system(), but Notepad, which needs a separate window, does not run:

来自文档对于 system():

最重要的区别是在类 Unix 系统上启动一个 shell,然后运行命令.在 Windows 上,命令直接运行 - 将 shell 用于通过 shell 运行命令的接口(默认情况下,Windows shell cmd.exe,它与 POSIX shell 有很多不同).

The most important difference is that on a Unix-alike system launches a shell which then runs command. On Windows the command is run directly – use shell for an interface which runs command via a shell (by default the Windows shell cmd.exe, which has many differences from a POSIX shell).

这篇关于R 系统函数总是返回错误 127的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆