Skip to content

Instantly share code, notes, and snippets.

@dketov
Created December 15, 2011 11:49
Show Gist options
  • Save dketov/1480835 to your computer and use it in GitHub Desktop.
Save dketov/1480835 to your computer and use it in GitHub Desktop.
Протокол Telnet
# -*- encoding: utf-8 -*-
"""
Получение списка файлов в домашнем каталоге
"""
import getpass
import sys
import telnetlib
HOST = "localhost"
user = raw_input("Enter your remote account: ")
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("ls\n")
tn.write("exit\n")
print tn.read_all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment