Module: OrangeLib::CommandLine

Included in:
Rest
Defined in:
lib/orange_lib/command_line.rb

Instance Method Summary collapse

Instance Method Details

#execute_command(command) ⇒ String

Execute a command line

Examples:

execute_command('echo $PATH')

Parameters:

  • command (String)

    command

Returns:

  • (String)

    String of output which will be print on screen when we execute the comman



10
11
12
13
14
15
16
17
18
19
# File 'lib/orange_lib/command_line.rb', line 10

def execute_command(command)
  output = ''
  Open3.popen2e(command) {|stdin, stdout_and_stderr, wait_thr|
    stdout_and_stderr.each{|line|
      puts line
      output << line
    }
  }
  output
end