user3863616
user3863616

Reputation: 195

How to catch an output of command executed with WinSCP .NET assembly using Session.ExecuteCommand

(...)
Session sess = new Session();
sess.Open(sessionParams);
(...)
sess.ExecuteCommand('/home/kit/count.sh').Check();

Using WinSCP .NET assembly I create a connection to my Linux host and execute a script. My problem is to catch result of script to C# variable. In this case is just a single string. I've found a properties of session object called output but I am really do not know how to use it.

Would you help me please

Upvotes: 2

Views: 1876

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202360

The Session.ExecuteCommand method returns an instance of CommandExecutionResult.

The CommandExecutionResult has a property Output.

CommandExecutionResult result = sess.ExecuteCommand('/home/kit/count.sh');
result.Check();
string output = result.Output;

Upvotes: 2

Related Questions