I've downloaded the trail for SecureBridge, looking to do some automation of certain actions on our linux servers. I'm having a few issues when using a TScSSHShell component with the NonBlocking property set to false.
I've set the TScSSHClient to connect on FormShow and disconnect on FormDestroy, but when running the following code, it complains saying "Cannot send data to server". Works fine with NonBlocking set to true, but that doesn't fit my use case:
Code: Select all
function TForm3.ExecCmd(ACommand: string): string;
var
sLine: string;
begin
Result := '';
ScSSHShell1.WriteString(ACommand + #13); // Blows up here
repeat
sLine := ScSSHShell1.ReadString;
if (sLine <> '') then begin
Result := Result + sLine;
end;
until (sLine = '');
end;
procedure TForm3.FormDestroy(Sender: TObject);
begin
if (ScSSHClient1.Connected) then
ScSSHClient1.Disconnect;
end;
procedure TForm3.FormShow(Sender: TObject);
begin
if (not ScSSHClient1.Connected) then
ScSSHClient1.connect;
end;
The command I attempted to send was 'echo "Hello World"'.
Running Delphi 10.2 Tokyo (Update 1).
Thanks for the help in advance,
Michael.