隐藏系统命令会导致ruby [英] hiding system command results in ruby

查看:130
本文介绍了隐藏系统命令会导致ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ruby中隐藏系统命令的结果有多容易?例如,我的一些脚本运行

How easy is it to hide results from system commands in ruby? For example, some of my scripts run

system "curl ..." 

我不想看到下载结果。

谢谢! p>

Thanks!

推荐答案

您可以使用更复杂的 popen3 分别控制STDIN,STDOUT和STDERR:

You can use the more sophisticated popen3 to have control over STDIN, STDOUT and STDERR separately if you like:

Open3.popen3("curl...") do |stdin, stdout, stderr, thread|
  # ...
end

如果要静默某些流可以忽略它们,或者如果重定向或解释该输出很重要,您仍然可以使用。

If you want to silence certain streams you can ignore them, or if it's important to redirect or interpret that output, you still have that available.

这篇关于隐藏系统命令会导致ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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