Class: Archive::OperatingSystem
- Inherits:
-
Object
- Object
- Archive::OperatingSystem
- Defined in:
- lib/archive/operating_system.rb
Overview
Note:
Copyright © 2014 by The Board of Trustees of the Leland Stanford Junior University. All rights reserved. See LICENSE for details.
A wrapper class around the systemu gem that is used for shelling out to the operating system and executing a command
Class Method Summary collapse
-
.execute(command) ⇒ String
Executes a system command in a subprocess.
Class Method Details
.execute(command) ⇒ String
Executes a system command in a subprocess. The method will return stdout from the command if execution was successful. The method will raise an exception if if execution fails. The exception’s message will contain the explaination of the failure.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/archive/operating_system.rb', line 19 def OperatingSystem.execute(command) status, stdout, stderr = systemu(command) if (status.exitstatus != 0) raise stderr end return stdout rescue msg = "Command failed to execute: [#{command}] caused by <STDERR = #{stderr.split($/).join('; ')}>" msg << " STDOUT = #{stdout.split($/).join('; ')}" if (stdout && (stdout.length > 0)) raise msg end |