Telnet Batch!

V

Vu Ngoc Son

Hi! Everyone. I want to connect to a several server by Telnet client and run
some similar command . Can I make a batch to do it insted of typing after
tel net to server?
 
T

Torgeir Bakken \(MVP\)

Vu said:
Hi! Everyone. I want to connect to a several server by Telnet
client and run some similar command . Can I make a batch to do
it insted of typing after tel net to server?
Hi,

A previous post about this:

From: "Alex K. Angelopoulos \(MVP\)" <[email protected]>
Subject: Re: Automate a telnet session
Date: Wed, 19 Feb 2003 17:46:01 -0500
Newsgroups: microsoft.public.scripting.vbscript,
microsoft.public.scripting.wsh,
microsoft.public.windows.server.scripting,
microsoft.public.windowsnt.misc

<quote>

There's no native automated telnet tool. It is theoretically somewhat
possible with a screenscraper and the NT4-era telnet client, but the
newer one doesn't work worth a diddle due to various oddities such as
screen control characters.

There are several telnet clients which can be automated; the "free"
ones include most prominently feature TeraTerm, IVT, and TelScript;
below is my quote of Torgeir quoting me on the three tools, for people
in windows.server.scripting (did I really say all this?<g>) :

================
.....There are several which are commercially available; the 2 which I
use consistently are TeraTerm Pro and IVT Telnet.

http://hp.vector.co.jp/authors/VA002416/teraterm.html is the home page
for TeraTerm; it is open and easy to use, but is beginning to age.

http://home.planet.nl/~ruurdb/IVT.HTM
IVT telnet is alive and kicking and has just gone "semi-commercial" -
if you don't need Kerberos support, you can get it for free also.

and then we have this one ;-)

From: Alex K. Angelopoulos \(MVP\) ([email protected])
Subject: Telnet from WSH - AND IT'S ABOUT FLIPPIN' TIME!!!!!
Newsgroups: microsoft.public.scripting.wsh
Date: 2002-10-25 19:28:03 PST
http://groups.google.co.uk/group/microsoft.public.scripting.wsh/browse_frm/thread/4a5ba77557c49026/

================

As for scripts to handle this, the TeraTerm ones are easy. The web
server I use is experimental and is not listening for uploads right
now, so I can't get my TTL scripts transferred, but a short set will
be there "soon" at
http://dev.remotenetworktechnology.com/files/ttscripts.zip


In the interim, here's a TeraTerm script that logs on to a Win2K server
via Telnet and does a password change. Details of the logon sequence
and characters to wait for will vary depending on the OS/type of the
system to which you connect.


; 1 - we set variables - prompts and the passwords
UsernamePrompt = 'login:'
Username = 'administrator'
PasswordPrompt = 'password:'
;Current password
;New password (assumes a password change)
Password = 'modron'
NewPassword = 'modron'
;this is the LOCAL log file
PathtoLogFile = 'c:\data\logs\w2klog.txt'

;2 - we connect
connect param2

;3 - then we log in
wait UsernamePrompt
sendln Username
wait PasswordPrompt
sendln Password

;4 - wait for the w2k prompt; if it doesn't come in 5 seconds,
; assume its OK
wait '>'
timeout=5

;5 - Login is done, so we start a log, 0 for text not binary,
; 1 for append not overwrite
logopen PathtoLogFile 0 1

;6a - Kludge - since I can't echo params to log,
' we'll do an ipconfig to capture address
sendln 'ipconfig'
wait '>'

;6b - Now we do the password change and exit
sendln 'net user ' Username ' *'
wait 'user:'
sendln NewPassword
wait 'confirm'
sendln NewPassword
wait '>'
sendln 'exit'

;7 - Stop logging
logclose

</quote>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top