Skip to content

Instantly share code, notes, and snippets.

@damm
Forked from anonymous/gist:186245
Created September 13, 2009 17:16
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 damm/186246 to your computer and use it in GitHub Desktop.
Save damm/186246 to your computer and use it in GitHub Desktop.
ruby_block "something" do
block do
require 'expect'
require 'pty'
PTY.spawn( 'dnscache-setup' ) do |read,write,pid|
write.sync = true
$expect_verbose = false
read.expect( '(press enter to begin setup, or press control-C to abort)', 30 ) do |response|
write.print "\n" if response
end
read.expect( '[/var]' ) do |response|
# use default path /var/dnscachex
write.print "\n" if response
end
read.expect( 'IP to bind cache to [127.0.0.1]> ') do |response|
write.print "192.168.102.106\n" if response
end
read.expect( 'enter forward-to IP' ) do |response|
write.print( "192.168.1.1\n" ) if response
write.print( "\n" ) if response
end
read.expect( 'Enter IP>' ) do |response|
write.print( "192.168\n" ) if response
write.print( "\n") if response
write.print( "\n") if response
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment