Mike Ru Wrote:How can I write it into file?
I have a script
os.system is deprecated,use
subprocess.
For Python 2.7 or newer versions can use
check_output(),to cacth the output.
Example:
from subprocess import check_output
# Windows
out = check_output(['ping', 'google.com'])
# linux
#out = check_output(['ping', '-c', '4', 'google.com'])
print(out.decode('utf-8').strip())
Output:
Pinging google.com [108.177.14.102] with 32 bytes of data:
Reply from 108.177.14.102: bytes=32 time=63ms TTL=48
Reply from 108.177.14.102: bytes=32 time=64ms TTL=48
Reply from 108.177.14.102: bytes=32 time=63ms TTL=48
Reply from 108.177.14.102: bytes=32 time=63ms TTL=48
Ping statistics for 108.177.14.102:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 63ms, Maximum = 64ms, Average = 63ms