Skip to content

Instantly share code, notes, and snippets.

@ch1c0t
Created June 20, 2017 16:24
Show Gist options
  • Save ch1c0t/4f5358d65046a13371bd59e41a63a642 to your computer and use it in GitHub Desktop.
Save ch1c0t/4f5358d65046a13371bd59e41a63a642 to your computer and use it in GitHub Desktop.
require 'pty'
require 'expect'
qemu_command = "qemu-system-x86_64 -enable-kvm -cdrom ~/alpines/alpine-virt-3.6.2-x86_64.iso -nographic"
PTY.spawn qemu_command do |r, w, pid|
p pid
r.expect /localhost login: / do |message|
puts "The message is #{message}."
w.puts "root"
end
p r.read 10
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment