Code: Select all
import os
hostname = "192.168.0.255"
packetloss = os.system ("ping -c 5 " + hostname+ " | grep -oP '\d+(?=% packet loss')")
print (packetloss, 'is packet loss value') Code: Select all
100
(0, 'is packet loss value')Code: Select all
0
(0, 'is packet loss value')How can i make the above value the same? it always detect 0 on packet loss value.