Skip to content

Instantly share code, notes, and snippets.

@nmcspadden
Created November 6, 2015 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmcspadden/fae5ae14df2d12d1b00f to your computer and use it in GitHub Desktop.
Save nmcspadden/fae5ae14df2d12d1b00f to your computer and use it in GitHub Desktop.
ruby_block 'Server.app' do
block do
require 'open3'
require 'expect'
# start the servercmd with IO pipes to its input and from its out&error combined
cmd_in, cmd_out_err, thr = Open3.popen2e(servercmd, "setup")
# Here's where you use the minimal ruby expect library
cmd_out_err.expect 'Press Return to view the software license agreement.'
cmd_in.puts ''
cmd_out_err.expect '(y/N)'
cmd_in.puts 'y'
cmd_out_err.expect 'User name:'
cmd_in.puts username
cmd_out_err.expect 'Password:'
cmd_in.puts user_pw
cmd_out_err.read
cmd_in.close
cmd_out_err.close
end
action :run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment