Class: Recap::Support::ShellCommand
- Inherits:
-
Object
- Object
- Recap::Support::ShellCommand
- Defined in:
- lib/recap/support/shell_command.rb
Class Method Summary collapse
Class Method Details
.execute(*commands) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/recap/support/shell_command.rb', line 5 def self.execute(*commands) output, error = "", "" commands.each do |command| status = Open4::popen4(command) do |pid, stdin, stdout, stderr| output, error = stdout.read, stderr.read end unless status.success? = [ "Executing shell command failed.", " Command: #{command}", " Status: #{status.exitstatus}", " Message: #{error}" ].join("\n") raise end end output end |
.execute_interactive(command) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/recap/support/shell_command.rb', line 24 def self.execute_interactive(command) unless system(command) = [ "Executing shell command failed.", " Command: #{command}", " Status: #{$?.exitstatus}" ].join("\n") raise end end |