Module: J1::Utils::Exec1

Extended by:
Exec1
Included in:
Exec1
Defined in:
lib/j1/utils/exec1.rb

Instance Method Summary collapse

Instance Method Details

#run(*args) ⇒ Object

Runs a program in a sub-shell.

*args - a list of strings containing the program name and arguments

Returns a Process::Status and a String of output in an array in that order.



14
15
16
17
18
19
20
21
# File 'lib/j1/utils/exec1.rb', line 14

def run(*args)
  stdin, stdout, stderr, process = Open3.popen3(*args)
  out = stdout.read.strip
  err = stderr.read.strip

  [stdin, stdout, stderr].each(&:close)
  [process.value, out + ';' + err]
end