1

I made a wrapper in Ruby that does a bunch of stuff, sets environmental variables, then executes an external program using the Open3 library, passing arguments (and ENV) to the external process.

Everything is working very well, and I get real-time output from the external process. However, occasionally the external program will ask for input. My existing code does not accommodate this, providing input does not seem to work.

This is the function that runs the external program with options.

def run_tf(options = '--help')
  puts '-= Begin TerraForm Output =-'

  exit_code = 0

  Open3.popen2e("terraform #{options}") do |i, oe, t|
      oe.each { |line| puts line }
      exit_code = t.value.exitstatus
  end

  puts '-= End TerraForm Output =-'

  exit_code
end

How can I make this accept STDIN?

geekifier
  • 121
  • 4

0 Answers0