ich habe ein paar Schwierigkeiten mit Popen... folgendes möchte ich tun:
Ich möchte den Befehl /usr/sbin/fping -c5 8.8.8.8 ausführen, was mir auf der Shell folgendes liefert:
Code: Alles auswählen
/usr/sbin/fping -C5 8.8.8.8
8.8.8.8 : [0], 96 bytes, 5.25 ms (5.25 avg, 0% loss)
8.8.8.8 : [1], 96 bytes, 4.39 ms (4.82 avg, 0% loss)
8.8.8.8 : [2], 96 bytes, 3.52 ms (4.38 avg, 0% loss)
8.8.8.8 : [3], 96 bytes, 2.95 ms (4.02 avg, 0% loss)
8.8.8.8 : [4], 96 bytes, 5.40 ms (4.30 avg, 0% loss)
8.8.8.8 : 5.25 4.39 3.52 2.95 5.40
Folgendes hab ich in python gemacht:
Code: Alles auswählen
#!/usr/bin/env python
import subprocess
output = subprocess.Popen(["/usr/sbin/fping", "-c8" ,"8.8.8.8"] , stdout=subprocess.PIPE).communicate()[0]
print "-------Hier beginnt die Scriptausgabe--------"
print output
Code: Alles auswählen
Die Ausgabe ist folgende:
python check_latency.py
8.8.8.8 : xmt/rcv/%loss = 8/8/0%, min/avg/max = 3.00/5.84/9.51
-------Hier beginnt die Scriptausgabe--------
8.8.8.8 : [0], 96 bytes, 5.43 ms (5.43 avg, 0% loss)
8.8.8.8 : [1], 96 bytes, 4.08 ms (4.75 avg, 0% loss)
8.8.8.8 : [2], 96 bytes, 7.43 ms (5.64 avg, 0% loss)
8.8.8.8 : [3], 96 bytes, 3.53 ms (5.11 avg, 0% loss)
8.8.8.8 : [4], 96 bytes, 7.03 ms (5.50 avg, 0% loss)
8.8.8.8 : [5], 96 bytes, 9.51 ms (6.16 avg, 0% loss)
8.8.8.8 : [6], 96 bytes, 6.76 ms (6.25 avg, 0% loss)
8.8.8.8 : [7], 96 bytes, 3.00 ms (5.84 avg, 0% loss)
Code: Alles auswählen
8.8.8.8 : xmt/rcv/%loss = 8/8/0%, min/avg/max = 3.00/5.84/9.51
Ich verstehe nicht ganz warum, da ich doch stdout auf PIPE gesetzt habe....
mfg fl0