Skip to content

Instantly share code, notes, and snippets.

@romandobra
Last active August 23, 2024 08:04
Show Gist options
  • Save romandobra/9d81a553a6189e9761f10ab5dca9a1ca to your computer and use it in GitHub Desktop.
Save romandobra/9d81a553a6189e9761f10ab5dca9a1ca to your computer and use it in GitHub Desktop.
cat piped_script.sh | expect send-to-console.expect
#!/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