捕获退出状态和R中系统调用的输出

捕获退出状态和R中系统调用的输出,第1张

捕获退出状态和R中系统调用的输出

从R 2.15开始,

system2
stdout
和/或
stderr
为TRUE 时,会将返回值作为属性给出。这使获取文本输出和返回值变得容易。

在此示例中,

ret
最终是带有属性的字符串
"status"

> ret <- system2("ls","xx", stdout=TRUE, stderr=TRUE)Warning message:running command ''ls' xx 2>&1' had status 1 > ret[1] "ls: xx: No such file or directory"attr(,"status")[1] 1> attr(ret, "status")[1] 1


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5018924.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-15
下一篇2022-11-15

发表评论

登录后才能评论

评论列表(0条)

    保存