Created
September 12, 2012 06:40
-
-
Save mmb/3704738 to your computer and use it in GitHub Desktop.
Scripting VM virtual consoles from the host.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Writing to Linux virtual consoles to simulate user input: | |
s = "ls\n" | |
open('/dev/tty1','w') do |f| | |
s.each_char do { |c| f.ioctl(0x5412, c) } | |
end | |
# From the shell: | |
echo 7 | ruby -e "open('/dev/tty1', 'w') { |o| \$stdin.each_char { |c| o.ioctl(0x5412, c) } }" | |
# To the virtual console of a VM from the host: | |
echo -e "open('/dev/tty1', 'w') { |o| DATA.each_char { |c| o.ioctl(0x5412, c) } }\n__END__" > script.rb | |
echo 8 >> script.rb | |
"/Applications/VMware Fusion.app/Contents/Library/vmrun" -gu root -gp test CopyFileFromHostToGuest your.vmx script.rb /tmp/script.rb | |
"/Applications/VMware Fusion.app/Contents/Library/vmrun" -gu root -gp test runProgramInGuest your.vmx /usr/bin/ruby /tmp/script.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment