Popen-wrapper, which provides additional features
Add this line to your application's Gemfile:
gem 'execute', git: 'https://github.com/lscheidler/ruby-execute'
And then execute:
$ bundle
execute echo command
status = Execute::execute ['echo', 'hello world']
# print output
puts status.stdout
execute echo command and print command
status = Execute::execute ['echo', 'hello world'], print_cmd: true
execute echo command and print output
status = Execute::execute ['echo', 'hello world'], print_lines: true
execute false command and throw exception, because exitstatus > 0
status = Execute::execute ['false'], throw_exception: true
Bug reports and pull requests are welcome on GitHub at https://github.com/lscheidler/ruby-execute.
The gem is available as open source under the terms of the Apache 2.0 License.