Module: PipeExec

Defined in:
lib/pipe_exec.rb,
lib/pipe_exec/version.rb

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.run(command) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/pipe_exec.rb', line 4

def self.run(command)
  require 'pty'
  begin
    PTY.spawn(command) do |stdin, stdout, pid|
      begin
        stdin.each { |line| print line }
      rescue Errno::EIO
      end
    end
  rescue PTY::ChildExited
    puts "The child process exited!"
  end
end