Skip to content

Instantly share code, notes, and snippets.

@shalk
Created October 16, 2013 06:51
Show Gist options
  • Save shalk/7003628 to your computer and use it in GitHub Desktop.
Save shalk/7003628 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
"
@cutty853
Copy link

excellent !

@eric-create
Copy link

Thank you!

@frenchy35
Copy link

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