Arthur Andersen

Gem: EM::SystemCommand

eventmachinerubygem

I just published my first ruby gem. It’s called EM::SystemCommand and serves as an abstration to popen3 calls. You can easily execute system commands and handle the data that’s been written to their stdout or stderr.

Check it out its Github Page.

Here is a basic example:

EM.run do
  ps = EM::SystemCommand.new 'my_command' do |on|
    on.success do |ps|
      puts 'Success!'
    end

    on.failure do |ps|
      puts 'Failure!'
    end

    on.stdout.line do |line|
      puts "Line received: #{line}"
    end
  end

  ps.stdin << "some data"
end