import pexpect

host = "localhost 30001"
username = "cisco"
password = "cisco"
command = 'show ip int brief'

session = pexpect.spawn('telnet ' + host, timeout=20)

session.sendline('\r\n')

result = session.expect(['Username:', pexpect.TIMEOUT])
session.sendline(username)
result = session.expect(['Password:', pexpect.TIMEOUT])
session.sendline(password)
result = session.expect(['>', pexpect.TIMEOUT])
session.sendline('enable')
result = session.expect(['#', pexpect.TIMEOUT])
session.sendline(command)
result = session.expect(['#', pexpect.TIMEOUT])
print(session.before)


582d84521eea3ac836591a7dbd492fa11484a5a0
<mask token>

<mask token>
session.sendline('\r\n')
<mask token>
session.sendline(username)
<mask token>
session.sendline(password)
<mask token>
session.sendline('enable')
<mask token>
session.sendline(command)
<mask token>
print(session.before)

<mask token>
host = 'localhost 30001'
username = 'cisco'
password = 'cisco'
command = 'show ip int brief'
session = pexpect.spawn('telnet ' + host, timeout=20)
session.sendline('\r\n')
result = session.expect(['Username:', pexpect.TIMEOUT])
session.sendline(username)
result = session.expect(['Password:', pexpect.TIMEOUT])
session.sendline(password)
result = session.expect(['>', pexpect.TIMEOUT])
session.sendline('enable')
result = session.expect(['#', pexpect.TIMEOUT])
session.sendline(command)
result = session.expect(['#', pexpect.TIMEOUT])
print(session.before)

import pexpect
host = 'localhost 30001'
username = 'cisco'
password = 'cisco'
command = 'show ip int brief'
session = pexpect.spawn('telnet ' + host, timeout=20)
session.sendline('\r\n')
result = session.expect(['Username:', pexpect.TIMEOUT])
session.sendline(username)
result = session.expect(['Password:', pexpect.TIMEOUT])
session.sendline(password)
result = session.expect(['>', pexpect.TIMEOUT])
session.sendline('enable')
result = session.expect(['#', pexpect.TIMEOUT])
session.sendline(command)
result = session.expect(['#', pexpect.TIMEOUT])
print(session.before)

import pexpect

host = "localhost 30001"
username = "cisco"
password = "cisco"
command = 'show ip int brief'

session = pexpect.spawn('telnet ' + host, timeout=20)

session.sendline('\r\n')

result = session.expect(['Username:', pexpect.TIMEOUT])
session.sendline(username)
result = session.expect(['Password:', pexpect.TIMEOUT])
session.sendline(password)
result = session.expect(['>', pexpect.TIMEOUT])
session.sendline('enable')
result = session.expect(['#', pexpect.TIMEOUT])
session.sendline(command)
result = session.expect(['#', pexpect.TIMEOUT])
print(session.before)

