OVERVIEW

Project shell_command
Homepage https://github.com/robgleeson/shell_command
Wiki https://github.com/robgleeson/shell_command/wiki
Documentation http://rubydoc.info/gems/shell_command/frames
Author Rob Gleeson

DESCRIPTION

Spawning shell commands in Ruby is already pretty nice but I think we can do better. shell_command tries to do it better by providing an object that gives you access to information about the command you've executed. If you have spawned shell commands and wondered was the command successful (e.g: did it exit with a status code of 0?), and what did it write to the standard error or standard output streams then shell_command might be useful to you.

EXAMPLES

The first example lets you handle a failure of a command yourself, but the second example assumes you want a exception raised on failure.

1.

ShellCommand.run "ls" do |command|
  if command.success?
    puts command.stdout
  else
    puts "Looks like `ls` had problems executing."
  end
end

2.

begin
  ShellCommand.run! "ls"
rescue ShellCommand::Exception => e 
  p e.message
end

SUPPORTED PLATFORMS

  • Rubinius (1.9 mode)
  • CRuby 1.9+

LICENSE

See LICENSE.txt