| Class | ExtendedCommand |
| In: |
lib/webgen/extcommand.rb
|
| Parent: | Object |
Allows one to get stdout and stderr from an executed command. Original version by Karl von Laudermann in ruby-talk 113035
| err_text | [R] | |
| out_text | [R] | |
| ret_code | [R] |
# File lib/webgen/extcommand.rb, line 9
9: def initialize( command )
10: tempfile = Tempfile.new( 'webgen' )
11: tempfile.close # So that child process can write to it
12:
13: # Execute command, redirecting stderr to temp file
14: @out_text = `#{command} 2> #{tempfile.path}`
15: @ret_code = $? >> 8
16:
17: # Read temp file
18: tempfile.open
19: @err_text = tempfile.readlines.join
20: tempfile.close
21: end