Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

Ideas?

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

All result in the following to the console:

--- 10.1.1.1 hping statistic ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 1.1/1.1/1.1 ms
share|improve this question
    
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
    
That did it, thanks! –  schroeder Feb 18 '12 at 0:03

1 Answer 1

up vote 1 down vote accepted

As @mark-wagner said, the correct syntax is

hping3 10.1.1.1 -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 10.1.1.1 -c 1 -q ) >/dev/null

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

share|improve this answer
    
This put me on the alternate track of: hping3 10.1.1.1 -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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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