Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

telnet in vbscript (client side)

Status
Not open for further replies.

diembi

Programmer
Sep 22, 2001
238
ES
Hello!!!
Is possible create a telnet connection to a LINUX RH from a vbscript in the client side????

Thanks for all!!!!
 
The answer is yes, and yes!

If the box at the other end is simple enough you can just use the Winsock ActiveX Control.

When I say simple I mean that some "Telnet" servers are actually little more than a TCP socket server on port 23.

However most Telnet servers (and clients) are substantially "smarter" than this, and implement a good deal more than shoving a stream of bytes back and forth.

Here is a sample of a short session with the Windows XP Telnet Server:
Code:
ÿý%ÿû.ÿû.ÿý'ÿý.ÿ
ý.ÿû.
ÿü%
Welcome to Micro
soft Telnet Serv
ice ..
ÿý.ÿý.ÿü'ÿü.ÿü.ÿ
þ.
..login: 
b
b
o
o
b
b
..
..password: 
z
o
r
r
o
..
ÿý.
ÿû.
ÿú..ÿð
ÿú..ANSIÿð
.[1;1H*=========
================
================
================
======          
      .[2;1HWelc
ome to Microsoft
 Telnet Server. 
                
                
            .[3;
1H*=============
================
================
================
==              
  .[4;1HC:\Docum
ents and Setting
s\Bob.DOXIE.004>
                
                
        .[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.[1
4;1H.[K.[15;1H.[
K.[16;1H.[K.[17;
1H.[K.[18;1H.[K.
[19;1H.[K.[20;1H
.[K.[21;1H.[K.[2
2;1H.[K.[23;1H.[
K.[24;1H.[K.[25;
1H.[K.[4;41H
e
e
x
x
i
i
t
t
..
As you can see it looks pretty wacky in places.

Part of this is Telnet Option Negotiation. That's the stuff that looks like funny y's and u's and stuff. Most of the periods are non-printable control characters like ESC, CR, and LF.

The other strings of stuff that have a lot of ['s and digits and semicolons are part of the terminal emulation escape sequences. In the example these are ANSI terminal sequences. If you look closely above just after the login you can see the client offering ANSI emulation and the server accepting it. Speaking of the login, notice the user ID being echoed back, but the password not being echoed?

So if you want to use Winsock you need to handle all this stuff.

To go this route I'd recommend a tool like TCPTap which I used to capture the Telnet session above. You'll need something to see what's going on as you develop your code. There is a free, non-limited beta version at:



Another possibility is to locate or purchase a Telnet ActiveX Control (OCX) or DLL that handles most of this funny business for you and just passes text back and forth. I haven't seen any for free that worked.


A third possibility is to create your own component (OCX or DLL) in Visual Basic or C++ to then be used from your scripts.


The only other thing I can think of is to find somebody's Telnet client application that exposes an automation interface, much like Office products do. Then your script could start a copy of that Telnet client and pull its puppet strings to make it dance to your tune.


Well wait... it is possible for recent versions of WSH to start an external program and "plug in to" the program's stdin and stdout streams to drive it. If you had a command-prompt Telnet client that was fairly simple and used stdin/stdout for console I/O you could take control of that too. I don't know of one, but it might be out there.


So the answer is that it can be done! :)

It just isn't easy. :-(
 
Hello dilettante,
Your wide response is very interesting and think that the own ocx option is the best.
Actually i use a link in the web page that open a .bat file where there is a call telnet to Linux server in msdos mode.

Thanks for all and regards.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top