I wish to suppress all output to stdout (console) from hping3 from a bash script, but everything I try results in the statistics still being displayed, even tho the individual ping results are suppressed.

I've tried redirecting different ways, command line switch '-q' and nothing works.


hping3 -c 1 -q > \dev\null
hping3 -c 1 -q > logfile.txt
hping3 -c 1 -q 1>\dev\null

All result in the following to the console:

--- hping statistic ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 1.1/1.1/1.1 ms
  • Can you be more specific about what methods of redirection you've tried? Sending stdout and stderr to /dev/null should quiet it down. – Shane Madden Feb 17 '12 at 23:26
  • 3
    The correct syntax is hping ... > /dev/null 2>&1 – Mark Wagner Feb 17 '12 at 23:46

As @mark-wagner said, the correct syntax is

hping3 -c 1 -q >/dev/null 2>&1

This redirects standard output to a bit-bucket file called /dev/null, and then redirects standard error to the same place.

If this was insufficient (for example, output not on standard error or standard out) then you could do this:

( hping3 -c 1 -q ) >/dev/null

This should work, no matter where the output is directed - I think.

  • This put me on the alternate track of: hping3 -c 1 2> /dev/null, which displays the packet results, but not the summary statistics at the end. Thank you everyone. – schroeder Feb 18 '12 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.