It would appear that the output from hping is fully buffered when piped to perl for further line-by-line processing, so piping hping to perl doesn't work.
hping --icmp-ts example.ca | perl -ne 'if (/Originate=(\d+) Receive=(\d+) Transmit=(\d+)/) { ($o, $r, $t) = ($1, $2, $3); } if (/tsrtt=(\d+)/) { print $r - $o, " ", $o + $1 - $t, "\n"; }'
How do I change hping from being fully buffered to being line buffered when piped?
Not a duplicate of the following question, since no solution works in OpenBSD base:
unbufferandstdbufaren't available in BSD? – slm Nov 24 '13 at 12:23stdbufisn't in OpenBSD.unbufferis, but it isn't immediately obvious: you need to install theexpectport. – Gilles 'SO- stop being evil' Nov 24 '13 at 21:40unbuffer, replacingifwith$|++;ifmakes no difference; I would imagine that it's because you can't change the buffering after the fact – cnst Oct 03 '17 at 06:28