I'm new to Python and to pexpect, but not to TCL expect. I have a super simple script that connects to a Cisco router via SSH and queries the arp table for a mac address. I want to retrieve the corresponding IP address. Here are the lines of interest:
branchConnection.sendline('sh ip arp | i 00c0.b7')
time.sleep(1)
branchConnection.expect('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
print(str(branchConnection.match.group(0)))
It prints b'10.198.7.10'
When I look at the pexpect.pty_spawn.spawn object it shows:
buffer (last 100 chars): b' 2 00c0.b790.b8c6 ARPA GigabitEthernet0/0.100\r\nRTR-01#'
before (last 100 chars): b'sh ip arp | i 00c0.b7\r\nInternet '
after: b'10.198.7.10'
Everything is encased in b' '
I'm assuming this is normal? Can someone please explain what is going on? I'm having trouble finding anything that explains what this means. How can I get pexpect to just return the IP address without b''?