Module: Exec

Included in:
Tablomat::IPSet, Tablomat::IPTablesBase
Defined in:
lib/tablomat/exec.rb

Overview

Module defined in exec.rb File to execute Commands

Class Method Summary collapse

Class Method Details

.exec(cmd) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tablomat/exec.rb', line 8

def self.exec(cmd)
  errfile = Tempfile.new('tablomat')
  stdout = `#{cmd} 2> #{errfile.path}`
  unless $CHILD_STATUS.success?
    err = errfile.read
    errfile.close
    errfile.unlink
    raise err.to_s
  end
  stdout
end