How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?
相关问题
- How to get the return code of a shell script in lu
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
- reference to a method?
- Invoking Mirth Connect CLI with Powershell script
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- In IntelliJ IDEA, how can I create a key binding t
- Ruby using wrong version of openssl
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
My favourite is Open3
Using the answers here and linked in Mihai's answer, I put together a function that meets these requirements:
As a bonus, this one will also return STDOUT in cases where the shell command exits successfully (0) and puts anything on STDOUT. In this manner, it differs from
system
, which simply returnstrue
in such cases.Code follows. The specific function is
system_quietly
: