diff options
-rw-r--r-- | lib/puppet/util.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index b07b2dfec..a5f3c5b1a 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -268,7 +268,10 @@ module Util # Execute the desired command, and return the status and output. # def execute(command, failonfail = true, uid = nil, gid = nil) - def execute(command, arguments = {:failonfail => true, :combine => true, :stdin => "/dev/null"}) + # :combine sets whether or not to combine stdout/stderr in the output + # :stdinfile sets a file that can be used for stdin. Passing a string + # for stdin is not currently supported. + def execute(command, arguments = {:failonfail => true, :combine => true}) if command.is_a?(Array) command = command.flatten.collect { |i| i.to_s } str = command.join(" ") @@ -321,7 +324,11 @@ module Util # Child process executes this Process.setsid begin - $stdin.reopen(arguments[:stdin]) + if arguments[:stdinfile] + $stdin.reopen(arguments[:stdinfile]) + else + $stdin.reopen("/dev/null") + end $stdout.reopen(output_file) $stderr.reopen(error_file) @@ -466,4 +473,3 @@ require 'puppet/util/execution' require 'puppet/util/logging' require 'puppet/util/package' require 'puppet/util/warnings' - |