We have long running java-applications that get started vie ssh on a unix server. This applications do log frequently directly on stdout. If we use ScSSHShell.Command to execute those applications we don't get any response till the command has finished. If we use NonBlocking mode we get the messages via AsyncReceive, but how can we prevent the user from disconnecting the sshclient/sshshell while an command ist still executing? Is there a property "active" that we can test before allow disconnecting?
Best regards
Daniel
AsyncReceive / "Connection-State" / Long Runs
You can use the Disconnect method at any moment, but the fact that the connection waits the end of executing command or does not depends on the server. If you want to forbid user to disconnect while a command is still being executed, you should process ending of the execution yourself, because in every case it will be processed differently.
The TScSSHShell.Connected property determines whether the connection is established.
The TScSSHShell.Connected property determines whether the connection is established.
The method ScSSHShell.Command is the proper way to do that i think, but we don't get any response till the process has finished.Dimon wrote:If you want to forbid user to disconnect while a command is still being executed, you should process ending of the execution yourself, because in every case it will be processed differently.
In Indy we use REXEC to do that, start the process and the procedure waits till it is has finished, but we get the servermessges via the IDLog-Event.
How can i check that the process is still active, do i have to "poll" the unix processlist?
If you mean the ExecuteCommand method, then it uses another connection type to send a single command execution.
In order to use the nonblocking mode, you should know when the command execution is finished. If the secure session is closed after the execution is finised, you can use the TScSSHShell.Connected property and close the connection after this property becomes False.
In order to use the nonblocking mode, you should know when the command execution is finished. If the secure session is closed after the execution is finised, you can use the TScSSHShell.Connected property and close the connection after this property becomes False.
Yes, i mean the ExecuteCommand method. But does the WriteString method do not work the same way in "blocking mode"?Dimon wrote:If you mean the ExecuteCommand method, then it uses another connection type to send a single command execution.
That's my problem, i don't know when the command execution is finished becaus we remote start software from thrid party developers and have to wait until it has finished to start our own methods afterwards. But we must get the status output of this command while they where executed to get a feedback for our user about what's going on.Dimon wrote:In order to use the nonblocking mode, you should know when the command execution is finished.
No. ExecuteCommand only sends one command to SSH server, SSH server executes this command and closes the connection. Therefore ExecuteCommand knows about the ending of the command execution and returns the result.dfried wrote:Yes, i mean the ExecuteCommand method. But does the WriteString method do not work the same way in "blocking mode"?
SSH protocol does not make provision to determine the end of the command execution.dfried wrote:That's my problem, i don't know when the command execution is finished becaus we remote start software from thrid party developers and have to wait until it has finished to start our own methods afterwards. But we must get the status output of this command while they where executed to get a feedback for our user about what's going on.