Command buffering control

Thu 31 December 2015 by admin

Debugging output from hping3 using grep via pipes doesn't show any result. It's because hping3 output is buffered, to make things working as you expect use tool called stdbuf from coreutils package in ubuntu and:

# stdbuf -oL hping3 -S -p 80 | grep <lookfor>

it means that each line is buffered not the whole stream. Imagine you can pass output buffered by line, so you can get live stats like in this ping example:

$ ping <host> | stdbuf -oL cut -d'=' -f4 | stdbuf -oL awk '{split($1,a,"."); print a[1]}'  | xargs -L 5 | stdbuf -oL sed 's/ /\n/g' | uniq -c

you are only interested in response time, you measure uniq count values in 5 probes at once.