-
-
Save trukhinyuri/706f2eae53bcbe819bdd810f6c704f83 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 | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment