Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


What exception? Please attach logs.


That syntax seems to be working now, the exception was actually being generated somewhere else.

Now I'm having trouble trying to capture the results of my ls command. ExecuteCommand() seems to generate an exception regardless of the success or failure of the command. I try to compare CommandExecutionResult.Output immediately after executing the command but that code is never executed because execution has jumped to the exception -
CommandExecutionResult ceResult = session.ExecuteCommand("ls /www");
if (ceResult.Output.ToUpper().Contains("NO SUCH FILE OR DIRECTORY"))

I've got the help doco on how to capture results of operations, but I'm still unsure what to do. Do I need to create an instance of one of the OperationResultBase? If so, is there an example of how that is done following ExecuteCommand()?


Re: Correct syntax for CommandExecutionResult?

The second syntax is correct (assuming the session is not null).

If you have problems, we need complete example.

Correct syntax for CommandExecutionResult?


What is the correct syntax for getting an instance of CommandExecutionResult?
I've tried -
string ceResult = session.ExecuteCommand("ls -al").Output;

CommandExecutionResult ceResult = session.ExecuteCommand("ls " + sft.destFile);

I've tried throwing in the new keyword as well, but all of these result in the exception -
System.NullReferenceException: 'Object reference not set to an instance of an object.'