~ubuntu-branches/ubuntu/wily/bandit/wily-proposed

« back to all changes in this revision

Viewing changes to examples/imports-telnetlib.py

  • Committer: Package Import Robot
  • Author(s): Dave Walker (Daviey)
  • Date: 2015-07-22 09:01:39 UTC
  • Revision ID: package-import@ubuntu.com-20150722090139-fl0nluy0x8m9ctx4
Tags: upstream-0.12.0
ImportĀ upstreamĀ versionĀ 0.12.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import telnetlib
 
2
import getpass
 
3
 
 
4
host = sys.argv[1]
 
5
 
 
6
username = raw_input('Username:')
 
7
password = getpass.getpass()
 
8
tn = telnetlib.Telnet(host)
 
9
 
 
10
tn.read_until("login: ")
 
11
tn.write(username + "\n")
 
12
if password:
 
13
    tn.read_until("Password: ")
 
14
    tn.write(password + "\n")
 
15
 
 
16
tn.write("ls\n")
 
17
tn.write("exit\n")
 
18
 
 
19
print(tn.read_all())