Aber ob das Inhaltlich und fachlich in Ordnung ist, das weiß ich nicht.
Hier der Code:
Code: Alles auswählen
import subprocess
from datetime import datetime
IP = "192.168.178.1"
pr = subprocess.Popen(["ping", IP], stdout=subprocess.PIPE)
for line in pr.stdout:
data = datetime.now().strftime('%H:%M:%S--%d-%m-%Y')
ping1 = str(line)
ping = data + " " + ping1 + "\n"
txt = open("/home/matze/pingtime.txt", "a")
txt.write(ping)
txt.close()