frontkick
testing ruby: 1.9.2, 1.9.3, 2.0.0;
Frontkick is a gem to execute a command and obtain exit_code, stdout, stderr simply.
What is This For?
Ruby's Kernel.#system
method does not return STDOUT and STDERR.
Ruby's back quote (``) returns STDOUT, but does not return STDERR.
With frontkick, you can easily get the exit code, STDOUT, and STDERR.
USAGE
gem install frontkick
Basic Usage
result = Frontkick.exec("echo *")
puts result.successful? #=> true if exit_code is 0
puts result.stdout #=> stdout output of the command
puts result.stderr #=> stderr output of the command
puts result.exit_code #=> exit_code of the command
puts result.duration #=> the time used to execute the command
puts result.status #=> alias to exit_code
Escape Command
result = Frontkick.exec(["echo", "*"]) #=> echo the asterisk character
Timeout Option
Frontkick.exec("sleep 2 && ls /hoge", :timeout => 1)
Exclusive Option
Prohibit another process to run a command concurrently
Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock") # raises Fontkick::Locked if locked
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright
Copyright (c) 2013 Naotoshi SEO. See LICENSE for details.