Telnet problem - WeOnlyDo Discussion board

Telnet problem (wodSSH / wodSSH.NET)

by Maverick2004, Monday, February 14, 2005, 14:30 (7221 days ago)

Hi all
I´m having a bit of a problem using the Telnet protocol. I´ve successfully used SSHAuto to connect to Unix hosts, but i can´t
seem to get Telnet to work on Windows hosts. It looks like it´s
the WaitFor method that´s giving me the problem, i just times out.
If i don´t use it, the Execute method won´t fire.
[code]
Dim wodSSH1 As New wodSSH

With wodSSH1
.HostName = server
.Login = user
.Password = psw
.Port = 23
.Protocol = Telnet
.Blocking = True
.Connect
.WaitFor regex:[>] $ , 5
End With

If wodSSH1.DataReady > 0 Then wodSSH1.Receive
Trash = wodSSH1.Execute( find /I completed & LogWin & vbCrLf)
wodSSH1.Disconnect
[/code]

If i connect to the host using a regular telnet client, i get the
below when i connect, so what should i use as regex?

Welcome to Microsoft Telnet Service

login: administrator
password:

*===============================================================
Welcome to Microsoft Telnet Server.
*===============================================================
C:Documents and SettingsAdministrator>

Re: Telnet problem

by wodSupport, Monday, February 14, 2005, 14:34 (7221 days ago) @ Maverick2004

Maverick,

can you use nonregex waitfor, such as

ssh1.waitfor( C:\Documents and Settings\Administrator> )

( make sure it's exactly the same as command prompt), does that work?

Re: Telnet problem

by Maverick2004, Monday, February 14, 2005, 15:01 (7221 days ago) @ wodSupport

I printed what i receive to a textfile and it looks like the ouput is kinda screwed up, which probably causes the regex statement to be false. Any suggestions as to why?

[1;1H*=============================================================== [2;1HWelcome to Microsoft Telnet Server. [3;1H*=============================================================== [4;1HC:Documents and SettingsAdministrator> [5;1H[K[6;1H[K[7;1H[K[8;1H[K[9;1H[K[10;1H[K[11;1H[K[12;1H[K[13;1H[K[14;1H[K[15;1H[K[16;1H[K[17;1H[K[18;1H[K[19;1H[K[20;1H[K[21;1H[K[22;1H[K[23;1H[K[24;1H[K[25;1H[K[4;41H

Cheers!
Maverick

Re: Telnet problem

by wodSupport, Monday, February 14, 2005, 15:21 (7221 days ago) @ Maverick2004

Ah, yes, this explains it. You get a lot of ANSI sequences inside. I can suggest you try to set TerminalType = tty or dumb , and also try to set StripANSI = True. If none of that helps, I'm clueless. You could shorten waitfor expression in that case, and especially remove $ from the end (which means end of line) since it's obvious your command prompt does not occur at the end of the line (since ANSI follows it)

Kreso

Re: Telnet problem

by Maverick2004, Monday, February 14, 2005, 15:48 (7221 days ago) @ wodSupport

Thanks, that did the trick! Now i just have to figure out how to get the find /I command to actually work. =) That´s not a problem related to the wodSSH component, but rather a vb issue. If anyone has any other suggestions as to how i can read a text file on a remote windows host, and find certain lines within that file and print those lines to a local text file, that would be sweet. =)

Cheers!
Maverick

Re: Telnet problem

by Maverick2004, Monday, February 14, 2005, 16:21 (7221 days ago) @ Maverick2004

Ah, problem solved =)
[code]
If wodSSH1.DataReady > 0 Then wodSSH1.Receive
wodSSH1.Execute ( find /I completed, & LogWin & vbCrLf)
Trash = wodSSH1.Receive
wodSSH1.Disconnect
[/code]

Trash now holds the ouput i receive back. I also get the remote prompt
as a last line, i.e C:Documents and SettingsAdministrator> .
Is there a way to skip this last line directly in the command syntax?

Cheers!
Maverick

Re: Telnet problem

by wodSupport, Monday, February 14, 2005, 16:25 (7221 days ago) @ Maverick2004

Maverick,

not sure how you mean to remove last line. Perhaps you could use ReceiveLine? Is that what you had in mind? Or you need to do it from Received data? If so, wodSSH doesn't have solution for you, but some string parsing is needed.

Re: Telnet problem

by Maverick2004, Tuesday, February 15, 2005, 13:19 (7220 days ago) @ wodSupport

Hi again!
Jupp, solved it with some simple string parsing. =)

Thanks again!
Maverick