Delphi Console Application - WeOnlyDo Discussion board

Delphi Console Application (General questions)

by John, Wednesday, February 04, 2009, 05:36 (5771 days ago)

Hello Kreso,

I'm having difficulty connecting with a console application. I don't think it's because I'm not trapping any events. Is these something else that has to happen in a console app to trigger connect?

code follows (compiles and executes with no issues):

program console;

{$APPTYPE CONSOLE}

uses
SysUtils, Variants, Classes, OleCtrls, WODSSHLib_TLB, WODSSHKeyLib_TLB, OleServer, ActiveX;

var

wodSSH1: TwodSSH;
Keys1: TKeys;
bExec: Boolean;



begin
{ TODO -oUser -cConsole Main : Insert code here }

CoInitialize(nil);
bExec := False;
wodSSH1 := TwodSSH.Create(nil);
Keys1 := TKeys.Create(nil);
wodSSH1.Hostname := '192.168.49.355';
wodSSH1.Login := 'testaccount';
wodSSH1.Password := 'testpass';
wodSSH1.Authentication := authPassword;
wodSSH1.Protocol := SSH2;
wodSSH1.Port := 22;
WodSSH1.AllocatePty := True;
WodSSH1.Encryption := encAny;
WodSSH1.ShowStdErrorMessages := True;

wodSSH1.PrivateKey := keys1.PrivateKey[RSAkey];
WriteLn('Attempting to connect');
wodSSH1.Connect;
wodSSH1.Blocking := True;
wodSSH1.DataReady := 0;
sleep(1000);
WodSSH1.Disconnect;
CoUninitialize;
end.


Complete thread: