Files
linux-kernel-module-cheat/qemumonitor
Ciro Santilli bad30f513c qemumonitor: fix for qemu v2.12
Must use expect now for some reason, and I only know how to make it work
nicely if the arguments come from CLI arguments instead of stdin.

Document it on a dedicated section.

Fix #29
2018-05-26 22:19:19 +01:00

25 lines
897 B
Plaintext
Executable File

#!/usr/bin/env expect
# Ee have to use expect since QEMU 2.12: just piping commands
# into telnet stopped working at that version.
spawn telnet localhost 45454
set prompt "\n(qemu) "
expect $prompt
if {$argc > 0} {
send "[concat [join $argv " "]]\r"
expect $prompt
} else {
interact
}
# In order to treat input from stdin, we would need to differentiate between input from pipe vs terminal.
# For bash we can do it as:
# https://stackoverflow.com/questions/911168/how-to-detect-if-my-shell-script-is-running-through-a-pipe
# but no one knows for Tcl:
# https://stackoverflow.com/questions/43660612/how-to-check-if-stdin-stdout-are-connected-to-a-terminal-in-tcl
# One option would also be to have a bash wrapper that calls this tcl script.
# Related: https://stackoverflow.com/questions/10237872/expect-redirect-stdin
#while {[gets stdin line] > 0} {
#expect $prompt
#send "$line\r"
#}