root@proxmox1 ~ > ls -l /tmp/test_12002.ppm
/bin/ls: cannot access '/tmp/test_12002.ppm': No such file or directory
root@proxmox1 ~ > ./screenshot 12002
spawn qm monitor 12002
Entering Qemu Monitor for VM 12002 - type 'help' for help
qm> screendump /tmp/test_12002.ppm
qm> quit
root@proxmox1 ~ > ls -l /tmp/test_12002.ppm
-rw-r----- 1 root root 2359312 Mar 10 23:34 /tmp/test_12002.ppm
root@proxmox1 ~ > cat screenshot
#!/usr/bin/expect
set timeout 10
set id [lindex $argv 0]
spawn qm monitor $id
expect "qm>"
send -- "screendump /tmp/test_$id.ppm\r"
expect "qm>"
send -- "quit\r"
expect eof