I have already checked This Question but could not find what i'm looking for. I am running Windows (the client), and the server is a legacy mainframe type server.
Basically I need to write a script, python code or whatever, to send some know commands to the server via telnet, and preferable capture the output. Then return when done.
What's the best approach?
I've never used it myself, but maybe pexpect is what you need?
There's a python library for telnet connections that reads and writes from/to a telnet connection.
Check the link. It has some basic examples of what you are looking for.
Here's an example from the link:
It connects to a telnet server. Sends your login credentials and then executes the unix command
ls
. Then exits the session and prints all output from the telnet server.You may want to consider Exscript as well. It simplifies some of the easy tasks but for more complicated there is additional level of abstraction (Exscript is a scripting language in itself). Either way - worth checking out.
This thread is old but I thought I'd go ahead and post anyway. There is a prog called AutoMate that would most likely suit your needs well. It runs on Windows and is pretty easy to use.
More info on telnet automation - http://www.networkautomation.com/sales/terminal-emulation-automation/