ScSSHShell executeCommand doesn't work
Posted: Fri 28 Oct 2011 15:23
I've just purched SecureBridge and I'm trying to issue a command to an SSH Server using TScSSHShell.
I want to connect to the server, issue a command, and then return a result to the user. I want to do this in the background, rather than displaying the shell on screen (which is how the TScSSHShell works in the SecureBridge demo application). I have been running invalid commands to make sure an error message is written to the shell, and hence I have something to display (as far as I can work out, this is what should happen).
If I try using the executeCommand method, a blank string is returned (if the connection is set to be non blocking). If I set the connection to be blocking, the function doesn't return anything and the application hangs.
What am I doing wrong?
I'm using Delphi XE Professional, if that helps.
The code that I'm writing needs to run in the background, so I can't display a shell input screen to the user. The user enters some parameters on screen and clicks a button to run a command. For this reason, using writeString with non-blocking set to true is very inconvenient, because the onAsyncReceive event triggers several times (connecting to the server retrieves a welcome screen, as well as the command string and response). I'd have to do a lot of processing to check to see if the command has been run, so I know when I can disconnect the instance of TScSSHShell and return a result to the user.
I want to connect to the server, issue a command, and then return a result to the user. I want to do this in the background, rather than displaying the shell on screen (which is how the TScSSHShell works in the SecureBridge demo application). I have been running invalid commands to make sure an error message is written to the shell, and hence I have something to display (as far as I can work out, this is what should happen).
If I try using the executeCommand method, a blank string is returned (if the connection is set to be non blocking). If I set the connection to be blocking, the function doesn't return anything and the application hangs.
What am I doing wrong?
I'm using Delphi XE Professional, if that helps.
The code that I'm writing needs to run in the background, so I can't display a shell input screen to the user. The user enters some parameters on screen and clicks a button to run a command. For this reason, using writeString with non-blocking set to true is very inconvenient, because the onAsyncReceive event triggers several times (connecting to the server retrieves a welcome screen, as well as the command string and response). I'd have to do a lot of processing to check to see if the command has been run, so I know when I can disconnect the instance of TScSSHShell and return a result to the user.