ExecuteCommand issues
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
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