I want to do something easy, but I don't catch... I did many search on Google and I didn't find something!
I'm doing this:
from subprocess import Popen, PIPE
p1 = Popen(["fping", '-C10', '-B1', '-p500',
'-r1', '-s', '172.29.172.106'], stdout=PIPE)
output = p1.communicate()
So, python executes my command, communicate waits the return code, it works fine. But, I don't know why it displays the output... Like this :
172.29.172.106 : 13.50 18.56 13.22 13.42 13.39 187.62 13.34 13.51 13.36 26.35
1 targets
1 alive
0 unreachable
0 unknown addresses
0 timeouts (waiting for response)
10 ICMP Echos sent
10 ICMP Echo Replies received
0 other ICMP received
13.2 ms (min round trip time)
32.6 ms (avg round trip time)
187 ms (max round trip time)
4.530 sec (elapsed real time)
I just want to execute a command then redirect the output to a variable but I don't want to display the output because it floods my crontab log file!
So the question : how to use popen (or other function) to execute a command and redirect output to a variable without display it?
Best regards,