Topic "ExecuteCommand issues"

Author Message
Austen
[View user's profile]

Joined: 2012-08-14
Posts: 1
Hi,

We need to be able to execute various commands prior to retrieving sets of files from the server, and we are having some issues doing this with the RC of WinSCP.

First, we tried executing the command and waiting for the returned result e.g.

CommandExecutionResult result = session.ExecuteCommand("ps -ef | egrep \"srp\" | grep -v grep");

This works fine for simple commands, but failed for the example given above, returning immediately with:

Exception:WinSCP.SessionRemoteException: Missing parameter for command 'call'.
at WinSCP.SessionLogReader.Read(LogReadFlags flags)
at WinSCP.ElementLogReader.Read(LogReadFlags flags)
at WinSCP.ElementLogReader.Read(LogReadFlags flags)
at WinSCP.CustomLogReader.TryWaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.CustomLogReader.WaitForNonEmptyElement(String localName, LogReadFlags flags)
at WinSCP.Session.ExecuteCommand(String command)

We then tried hooking the OutputDataReceived and Failed events, which was a lot more successful in that the same command executed without exception and we got some data back. However, we are expecting multiline results, and the OutputDataReceived event is firing on each line received, with no obvious marker as to when the command output has been received in full.

So, my questions are these:

1) Any idea why the command does not work when waiting for the results of Session.ExecuteCommand, as in the first example?
2) When hooking the events, is there any way of telling when we have hit the end of the output for a command?

Thanks for the help, and what is shaping up to be a great product!

Austen
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
It works for me.

Can you set Session.DebugLogPath and attach or email me the log?
hcreel
[View user's profile]

Joined: 2012-09-25
Posts: 1
Location: Tampa, FL
If I try to execute a script that displays several messages, and then exits with a non-zero number, the CommandExecutionResult is never set because of the exception that is generated. So I cannot see any of the messages. How about adding a ReturnCode to the CommandExecutionResult and not generating an exception?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Will consider that. Meanwhile you can append noop command after the failing command to suppress the error exit code.
I.e.
session.ExecuteCommand("<your failing command> ; :");
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License