Archived Forum Post

Index of archived forum posts

Question:

SSH Channel Exit Status?

May 12 '17 at 07:09

What is the 'exit status' returned by CkSsh_GetChannelExitStatus(). I want to run a program on a remote machine using CkSsh_SendReqExec() and get the program's exit code when it completes (the number passed to exit(n)). Is the number returned by CkSsh_GetChannelExitStatus() the exit code I'm looking for?


Answer

Yes and no.

If you are calling SendReqExec, then the SSH channel is running your program directly, and in this case the exit status of your program is the exit status of the SSH channel.

If you started a shell session, and you're running your program via the remote shell, then No. The channel exit status is the exit status of the shell program (it is the remote shell that would receive the exit status of your program).