Created
October 16, 2013 06:51
-
-
Save shalk/7003628 to your computer and use it in GitHub Desktop.
virsh console with expect
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
#!/bin/bash | |
expect -c " | |
set timeout 10 | |
spawn virsh console cvm1 | |
expect { | |
\"Escape character\" {send \"\r\r\" ; exp_continue} | |
\"Escape character\" {send \"\r\r\" ; exp_continue} | |
\"login:\" {send \"root\r\"; exp_continue} | |
\"Password:\" {send \"111111\r\";} | |
} | |
expect \"~ #\" | |
send \"echo 123\r\" | |
expect \"~ #\" | |
send \"date\r\" | |
send \"exit\r\" | |
expect \"login:\" | |
send \"\" | |
expect eof | |
" |
I use this script all the time!
Thanks!
Anyway to make it wait to see a "Login:" during a reboot? This script assumes the VM is already up I am trying to find a way to execute as soon as the reboot is finished. Any ideas?
This is good.
excellent !
Thank you!
Hi, I’ve tryed to use it on centos 7, it work 1 time on 2 try, any explanation !? Thanks in advance
__
Philipp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice work! Thank you