Class: CommandShell

Inherits:
Object
  • Object
show all
Defined in:
lib/rawc/command_shell.rb

Instance Method Summary collapse

Instance Method Details

#execute(cmd) ⇒ Object

Raises:

  • (RuntimeError)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rawc/command_shell.rb', line 2

def execute cmd
  puts cmd
  str = ""
  status = 0

  STDOUT.sync = true
  IO.popen(cmd + " 2>&1") do |pipe| 
    pipe.sync = true
    while s = pipe.gets
      str += s
    end
  end

  puts str

  raise RuntimeError, STDERR if !$?.success?
  
  return str
end