delphi (General questions)
Hello,
I try this code in delphi
wodSSHCom1.Hostname := Edit1.Text;
wodSSHCom1.Login := Edit2.Text;
wodSSHCom1.Password := Edit3.Text;
wodSSHCom1.Protocol := ComboBox1.ItemIndex;
if ComboBox1.ItemIndex = 1 then wodSSHCom1.Port := 23; // for telnet
if ComboBox1.ItemIndex > 1 then wodSSHCom1.Port := 22; // for SSH
memo1.Text := '';
PrintList('Connecting...' + chr(13) + chr(10));
wodSSHCom1.Blocking:=true;
wodSSHCom1.Connect1; // Connect is protected keyword for Delphi,
// so wrapper moved our Connect to Connect1
memo2.Text:=wodSSHCom1.Execute('ls -l'+#10,'regex:[a-zA-z0-9]+@[a-zA-z0-9]+:[a-zA-z0-9~/]+[$ #>] $');
The connect is ok
But after the command execute i have msg
STATECHANGE: Sending data to server (from Connected to server - idle)
STATECHANGE: Connected to server - idle (from Sending data to server)
STATECHANGE: Receiving data from server (from Connected to server - idle)
STATECHANGE: Connected to server - idle (from Receiving data from server)
STATECHANGE: Receiving data from server (from Connected to server - idle)
STATECHANGE: Connected to server - idle (from Receiving data from server)
STATECHANGE: Receiving data from server (from Connected to server - idle)
STATECHANGE: Connected to server - idle (from Receiving data from server)
STATECHANGE: Receiving data from server (from Connected to server - idle)
STATECHANGE: Connected to server - idle (from Receiving data from server)
but the function wodSSHCom1Received is never call
What is the probleme ?
Re: delphi
Hi Arno,
Please try something like this in Delphi:
[code]
wodSSHCom1.Connect1;
wodSSHCom1.WaitFor ('regex:[$ #>] $');
wodSSHCom1.DataReady := 0;
memo2.Text := wodSSHCom1.Execute( ls -al + vbLf, 'regex:[$ #>] $');[/code]
Before you execute command using Execute Method you should wait for a prompt to done that. That's why I use WaitFor Method in my code.
More help for WaitFor Method you can find here:
http://www.weonlydo.com/SSH/Help/WODSSHLib~wodSSH~WaitFor.html
When using Execute Method you don't need to call wodSSH Receive Method. Execute Method should return response from server. In your case in memo2.
Let us know how it goes.
Regards,
Drazen
Re: delphi
Hi,
I try this but i have always the same problem
wodSSHCom1.Blocking:=true;
wodSSHCom1.Connect1; // Connect is protected keyword for Delphi,
// so wrapper moved our Connect to Connect1
wodSSHCom1.WaitFor ('regex:[a-zA-z0-9]+@[a-zA-z0-9]+:[a-zA-z0-9~/]+[$ #>] $');
wodSSHCom1.DataReady := 0;
memo2.Text := wodSSHCom1.Execute('ls -al' + #10, 'regex:[a-zA-z0-9]+@[a-zA-z0-9]+:[a-zA-z0-9~/]+[$ #>] $');
Regards,
Arno
Hi Arno,
Please try something like this in Delphi:
[code]
wodSSHCom1.Connect1;wodSSHCom1.WaitFor ('regex:[$ #>] $');
wodSSHCom1.DataReady := 0;
memo2.Text := wodSSHCom1.Execute( ls -al + vbLf, 'regex:[$ #>] $');[/code]Before you execute command using Execute Method you should wait for a prompt to done that. That's why I use WaitFor Method in my code.
More help for WaitFor Method you can find here:
http://www.weonlydo.com/SSH/Help/WODSSHLib~wodSSH~WaitFor.htmlWhen using Execute Method you don't need to call wodSSH Receive Method. Execute Method should return response from server. In your case in memo2.
Let us know how it goes.
Regards,
Drazen
Re: delphi
Arno,
What is the value of prompt when you connect to your server?
You can use that value in WaitFor and Execute Method.
Also did you try on my way using my values in regex?
Drazen
Re: delphi
Arno,
What is the value of prompt when you connect to your server?You can use that value in WaitFor and Execute Method.
Also did you try on my way using my values in regex?
Drazen
Re: delphi
Hello,
I have this when i am connect
ns25266 ~ #
Re: delphi
Arno,
When you use Execute method, the Received and PromptReceived events are internally blocked and won't be raised. This is due to fact that those methods take control of buffer, and when they are used, will automatically strip the received string out of it.
If you still wish the Received Event to be triggered, you should try using Send method instead.
Also, in your sample, does memo2.text get filled with the response to your command?
Regards,
Damba