I will apologize in advance that I am new to Python3 and stuck on understanding the actual output as opposed to what I am expecting to receive.
Here is my code:
import pexpect
ping = pexpect.spawn('ping -c 5 8.8.8.8')
result = ping.expect([pexpect.EOF, pexpect.TIMEOUT])
print(ping.before)
The actual output is a single line starting with "b" and \r\n added instead of the actual lines wrapping.
I expect this:
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=78.1 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=76.5 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=76.2 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=128 time=76.8 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=128 time=77.0 ms
But instead my output is one giant line:
b'PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.\r\n64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=78.1 ms\r\n64 bytes from 8.8.8.8: icmp_seq=2 ttl=128 time=76.5 ms\r\n64 bytes from 8.8.8.8: icmp_seq=3 ttl=128 time=76.2 ms\r\n64 bytes from 8.8.8.8: icmp_seq=4 ttl=128 time=76.8 ms\r\n64 bytes from 8.8.8.8: icmp_seq=5 ttl=128 time=77.0 ms\r\n\r\n--- 8.8.8.8 ping statistics ---\r\n5 packets transmitted, 5 received, 0% packet loss, time 4004ms\r\nrtt min/avg/max/mdev = 76.214/76.951/78.149/0.683 ms\r\n'
Does anyone have any idea?