Paramiko how to detect if command executed using invoke_shell has finished
SSHClient.invoke_shell
is for implementing an interactive terminal sessions (like if you are implementing your own SSH terminal client), not for automating a command execution. A terminal is a black box with input and output. It does not have any API to execute a command and wait for it to complete.
Use SSHClient.exec_command
to execute the command and Channel.recv_exit_status
or Channel.exit_status_ready
to wait for it to complete.
See Wait until task is completed on Remote Machine through Python.