Post a reply

Options
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)

Options

Topic review

martin

What exception? Please attach logs.
will.waterston@gmail.com

Thanks,

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"))
{
    session.CreateDirectory(sft.destFile);
}

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()?

Thanks.
martin

Re: Correct syntax for CommandExecutionResult?

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

If you have problems, we need complete example.
will.waterston@gmail.com

Correct syntax for CommandExecutionResult?

Hi,

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

and
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.'

Thanks.