Quantcast
Channel: Rebex Q&A Forum - Recent questions and answers
Viewing all articles
Browse latest Browse all 3862

Null characters received in data from SshChannel.ExtendedDataReceived event

$
0
0

Hi,

My application runs SSH commands to an OpenSSH service running under WSL on Windows 10 using version 1.0.6755 of Rebex.SshShell.Full.

I am attempting to log the stderr response in a different colour to the stdout response. I also want to retrieve the exit code so that I can log a failure when the exitcode is non-zero.

I'm using the ExtendedDataReceived event to do this as shown in SshCommandRunner class code in this post: http://forum.rebex.net/342/ssh-runcommand-startcommand-for-stdout-stderr-and-exit-code.

As a test, I am running the command SshCommandRunner.RunCommand("cp feck /mnt/d/temp") where the file "feck" does not exist.

Sometimes the 'response' string in channel_ExtendedDataReceived contains the correct error message e.g. "cp: cannot stat 'feck': No such file or directory"

However, it often contains strange characters and repeats previous data e.g. "-status\0\0\0\0\u0001le or dir" followed by "-status\0\0\0\0\u0001le or directory\n"

Additionally, the ExitCode is sometimes 1 and sometimes 0.

Any idea why this could be happening? The post with the code sample is quite old now - is there a better way to do this now?

Thanks,
Dave


Viewing all articles
Browse latest Browse all 3862

Trending Articles