Discussion Locked

Telnet from a batch file on Win2k

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Can someone tell me how to use telnet in a batch file, and pass arguments to telnet from the batch file?

I need to write a batch file that will launch telnet, login, pass a couple of commands, and logout.

If it can't be done in a .bat or .cmd, a pointer to the appropriate scripting language and examples would be appreciated.

5 replies

by duwaned

Hi.

Do you know KixTart at all? There is a function in KixTart called "Sendkeys". This can be used in conjunction with KixTarts "Setfocus" fintion to achieve what you are wanting to do.

An example of the KixTart script would look something like this to send a mail message using Telnet and command line:

run "telnet Servername 25"
SetFocus("c:\WINNT\System32\cmd.exe")
sleep 5
SendKeys("HELO")
Sendkeys("{ENTER}")
sleep 1
Sendkeys("MAIL FROM: ")
Sendkeys("{ENTER}")
sleep 1
Sendkeys("RCPT TO: ")
Sendkeys("{ENTER}")
sleep 1
Sendkeys("DATA")
Sendkeys("{ENTER}")
sleep 1
Sendkeys("Helloo from the batch file!")
Sendkeys("{ENTER}")
sleep 1
Sendkeys(".")
Sendkeys("{ENTER}")
;Sendkeys("{ENTER}")
Sendkeys("Quit")
Sendkeys("{ENTER}")

I have tested this and it works well. You can modify it to suite your needs. If you need more help with Kixtart, give me a shout, or go to http://kixtart.org

Hope this helps you.
Regards.
Duwane

by pete.zerger

Not a bad suggestion, but we are not allowed to put Kixstart on our servers, as it conflicts with other scripting software we use.

by jb007

I can remember a way it used to be done at a data centre I used to work at previously, we used a terminal emulation program to telnet into a machine and then run a macro that we had written and assigned to a toolbar icon.

I believe the software was called Netterm.

good luck,

jb

This discussion is closed to new replies.