What I tried as below which giving me error message.
What I want: I actually want to ping N number of servers and traceroute it and result should be saved in a text file. No matter if it store in any other format too but it should be easy to understand and read.
Issue: Error related to Popen is not getting resolved however if you aware of any other method, please welcome to that too. Please help. Thanks in advance.
Note: I am using Windows 10
import subprocess
with open('ip-source.txt') as file:
IP = file.read()
IP = IP.splitlines()
for ip in IP:
with open('output.txt','ab') as out:
out.write(subprocess.Popen("ping " + ip))
===================== RESTART: F:/PingandTracert/Ping.py =====================
Traceback (most recent call last):
File "F:/PingandTracert/Ping.py", line 12, in <module>
out.write(subprocess.Popen("ping " + ip))
TypeError: a bytes-like object is required, not 'Popen'