Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trukhinyuri/706f2eae53bcbe819bdd810f6c704f83 to your computer and use it in GitHub Desktop.
Save trukhinyuri/706f2eae53bcbe819bdd810f6c704f83 to your computer and use it in GitHub Desktop.
virsh console with expect
#!/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