I'm attempting to ping an IP address in Windows with Python. I want to output the result of the ping into a text file, but I don't know how to do that with the subprocess.call function. I know how to write variables to a file, but I don't know how to assign anything from the subprocess.call to a variable.
For example, if I pinged, I would want the text file to look like this
Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Ping statistics for 127.0.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
How would I do this?