Last active
August 23, 2024 08:04
-
-
Save romandobra/9d81a553a6189e9761f10ab5dca9a1ca to your computer and use it in GitHub Desktop.
cat piped_script.sh | expect send-to-console.expect
This file contains hidden or 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
#!/usr/bin/expect -f | |
set timeout -1 | |
spawn virsh -c qemu:///system console vm1 | |
expect "Connected" | |
send "\r" | |
expect "debian-live login: " | |
send "root\r" | |
expect "Password: " | |
send "toor\r" | |
expect "Last login: " | |
expect "# " | |
while {[gets stdin line] != -1} { | |
send "$line\r" | |
expect "root@debian-live:" | |
} | |
send \004 | |
expect "STRING_ECHOED_FROM_PIPED_SCRIPT_WHEN_DONE" | |
send "exit\r" | |
expect "logout" | |
send "\x1b\r" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment