Skip to content

Instantly share code, notes, and snippets.

Created Sep 13, 2009
Embed
What would you like to 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment