Delphi connection trouble (wodSSH / wodSSH.NET)
I seem to have trouble connecting to OpenSSH. I have tried every possible combination for the second parameter in the execute method, but none of them work, including the suggested regex. The program always times out after 1 second (I set it to 1 second) and the script I'm trying to execute is never actually executed. I am using the latest licensed version of wodSSH as of about four days ago. The send method appears to work fine, but I need execute with blocking because I'm going to be sending some data back to the client.
here's the prompt:
[root@localhost ~]#
procedure TForm1.Button1Click(Sender: TObject);
begin
bExec := False;
wodSSH1.Hostname := Edit1.Text;
wodSSH1.Login := Edit2.Text;
wodSSH1.Password := Edit3.Text;
wodSSH1.Protocol := ComboBox1.ItemIndex;
if ComboBox1.ItemIndex = 1 then wodSSH1.Port := 23; // for telnet
if ComboBox1.ItemIndex > 1 then wodSSH1.Port := 22; // for SSH
memo1.Text := '';
PrintList('Connecting...' + chr(13) + chr(10));
wodSSH1.Blocking := True;
wodSSH1.Connect;
end;
procedure TForm1.wodSSH1Connected(Sender: TObject; ErrorCode: Smallint;
const ErrorText: WideString);
begin
if ErrorCode<>0 then
printlist('CONNECT error: ' + ErrorText + chr(13) + chr(10))
else
printlist('CONNECTED to ' + wodssh1.Hostname + chr(13) + chr(10));
wodSSH1.Execute('/root/create.sh aa.txt john000 u3277fhg59njmjv7y56nh' + #10, '[root@localhost ~]# ', 1)
end;
Re: Delphi connection trouble
Hi John,
This is what I did in VB6 and this works:
----------------------------
Dim WithEvents ssh1 As wodSSHCom
Set ssh1 = New wodSSHCom
ssh1.HostName = Hostname
ssh1.Blocking = True
ssh1.StripANSI = True
ssh1.Login = login
ssh1.Password = password
ssh1.Protocol = SSHAuto
ssh1.Connect
ssh1.WaitFor ( regex:[$ #>] $ )
If ssh1.DataReady > 0 Then ssh1.Receive
Debug.Print ssh1.Execute( script & vbLf, regex:[$ #>] $ )
ssh1.Disconnect
--------------------------------
And here is what I received from my server:
--------------------------------------
script
Script started, file is typescript
kreso1@knjiga:~
---------------------------------------
Maybe you shuold try set TimeOut Property to 0, I think that will help you.
And of course look at here:
http://www.weonlydo.com/index.asp?forum=1&action=view&topic=1143527077#1143532518
this looks like some similar problem like yours.
Regards,
Alan