0 votes
by (220 points)

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

1 Answer

+1 vote
by (70.2k points)
edited by
 
Best answer

UPDATE:

The issue was fixed in version 2018 R2.1.


It showed that this is a bug in the ExtendedDataReceived event. The received data can be overwritten before providing it to the event consumer.

We have fixed it. You can try the hotfix, which is available at https://www.rebex.net/getfile/1977a47e18034dc1a1ddd244bf0d45e0/RebexTotalPack-HotfixBuild6808-Trial-Binaries.zip

You can use this trial key:

// Add this line to your application to set your trial key before working with Rebex classes.
Rebex.Licensing.Key = "==AFq6gP2DYmHj+yh7bYWpmDGIm8zNJ5mOcifeKrc9ShEE==";

If you have already purchased a license, please send your order details to sales@rebex.net and we will send you full version of the hotfix.

Thank you for pointing to this. We are sorry for any inconveniences it may cause.

by (220 points)
Works well. Thanks for the quick fix.
...