隐藏系统命令导致红宝石 [英] hiding system command results in ruby
本文介绍了隐藏系统命令导致红宝石的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 ruby 中隐藏系统命令的结果有多容易?例如,我的一些脚本运行
How easy is it to hide results from system commands in ruby? For example, some of my scripts run
system "curl ..."
我不想看到下载结果.
推荐答案
你可以使用更复杂的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.
这篇关于隐藏系统命令导致红宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文