Question:
I want to send and execute commands on a unix server.
when I send the command I would like to update the user as to the status of the job. Even being able to say 'The job is still running' would be helpful. Is there a way to do this?
There are two ways to execute remote commands on a server:
Let's say you have a command that takes a long time, and at the very end prints "Command Completed" to stdout before it exits. In both of the above cases, after starting the remote command, your program could try to receive the stdout by calling ChannelReadAndPoll. Nothing would be received until the very end when the "Command Completed" is emitted. There's really no way to know the status of your command -- unless you bake into your command something that periodically emits the status to stdout.
The solution is to modify your command (if possible) so that it emits status output to stdout as it runs. Then your SSH client program can receive the channel output and report the status.
Thank you.