telnet functions
Fredrik Lundh
effbot at telia.com
Wed Feb 9 11:43:36 EST 2000
Oliver Benduhn wrote:
> does anybody here has any good experiences with telnet over an Python
> script.
>
> There is an Telnet Module but it doesnt offer the functions i need.
really? (read on)
> i has to log me on with user-name and password and i have to start a
> Perl-Script on a Sun-Unix mashine.
hey, telnetlib can do that. piece of cake.
the following example (from the eff-bot guide) works
for me, at least. shouldn't be that hard to change the
"ls" call to run your perl script instead...
# File: telnetlib-example-1.py
import telnetlib
import sys
HOST = "spam.egg"
USER = "mulder"
PASSWORD = "trustno1"
telnet = telnetlib.Telnet(HOST)
telnet.read_until("login: ")
telnet.write(USER + "\n")
telnet.read_until("Password: ")
telnet.write(PASSWORD + "\n")
telnet.write("ls librarybook\n")
telnet.write("exit\n")
print telnet.read_all()
</F>
<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->
More information about the Python-list
mailing list