Trying to login to a Cisco router. It's not sending the right commands at the "--More--" prompt. I think it might have to do on what I'm sending. I need to have a space command sent when it gets to the More prompt.
It will send a "\" character, but will net send a " " or any random letter either.
Current Code:
import pexpect
import sys
import os
import getpass
hostname = "router-2"
username = raw_input('Enter Your username: ')
password = getpass.getpass('Password:')
fout = file('agglog.txt','w')
child = pexpect.spawn('ssh %s@%s' % (username, hostname))
child.logfile_read = fout
child.expect('Password:')
child.sendline(password)
child.expect('>')
child.sendline('enable')
child.expect('Password:')
child.sendline(password)
child.expect('#')
child.sendline('show processes cpu history')
i = child.expect(["--More--","#"])
if i==0:
child.sendline(' ') ###PROBLEM IS HERE
else:
child.sendline('show processes cpu | i Core 0|Core 1')
child.expect('#')
child.sendline('logout')
Again, at the --MORE-- prompt it just hangs like it's waiting for something when trying to send a space command. On Cisco routers, when you press space at that prompt it displays more output. "terminal length 0" is not an option in this case due to permissions.
Any help is greatly appreciated.
Edit:
Here is what the output looks like:
router-2#show processes cpu history
History information for system:
111112222222222111111111122222111111111122222111111111111111
777770000000000999998888833333888889999900000999998888899999
100
90
80
70
60
50
40
30
20 ************************************************************
10 ************************************************************
0....5....1....1....2....2....3....3....4....4....5....5....
0 5 0 5 0 5 0 5 0 5
CPU% per second (last 60 seconds)
222222222222222222221222222222222222222222222222222222222222
342000300104111121019410422602031010060202210143001042120601
--More--