I don't know much about fping
, but something like this...
import subprocess
CMD = ['fping', 'param1', 'param2']
result = subprocess.check_output(CMD)
...will run fping param1 param2
, and put the output as a string into the result
variable, once the fping
process has terminated.
You can split the output into lines with result.splitlines()
.
Here's quick one-liner example using ping
to grab three ping times to localhost...
>>> [line.rpartition('=')[-1] for line in subprocess.check_output(['ping', '-c', '3', 'localhost']).splitlines()[1:-4]]
['0.028 ms', '0.023 ms', '0.025 ms']