Ex is a simple gem to make running external easy.
There are existing options such as Rubysh and Subprocess however these didn't really appeal to my world view.
Subprocess treats non-zero respones as exceptions - a design decision I do not agree with. Some utilities return non-zero status codes to indicate something other than their failure.
Add this line to your application's Gemfile:
gem 'ex'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ex
@result = Ex.run("ls -lah")
if @result.successful?
puts "Success"
end
@result.status_code
@result.output?
@result.stdout
@result.stderr
- Fork it ( https://github.com/yourabi/ex/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Squash your commits into a single commit
- Make sure all tests pass
- Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Make sure the PR can be merged cleanly