Live data from Hacker News

The best ping story I've ever heard

askapache.com

21–30 of 49 posts

Re: The best ping story I've ever heard

#21
post #6
post #2

Do someone know how to run a command for every line emitted in a unix pipe? I tried the oneliner in the linked story using Mac OS X’s `say`, but it doesn’t work with pipes.

cat input |while read a; do do_something_with $a; done

thank you so much!

Re: The best ping story I've ever heard

#22
post #2

Do someone know how to run a command for every line emitted in a unix pipe? I tried the oneliner in the linked story using Mac OS X’s `say`, but it doesn’t work with pipes.

xargs -n1 (-n is so it executes the command for each input) You'll also need sed -l to limit buffering. ping | sed -l 's/.*/ping/' | xargs -n1 say

perfect!

Re: The best ping story I've ever heard

#25
post #4

This is a good one too, although not strictly ping related. http://www.ibiblio.org/harris/500milemail.html

There's also this legendary Amazon review, which is strictly ping-related: http://www.amazon.com/review/R2VDKZ4X1F992Q

"At the same time each day (I suspect this is scheduled under cron)"

Spectacular.

Re: The best ping story I've ever heard

#30
post #9
post #7

Earlier quoted context omitted.

You might want to use "--unbuffered" flag in sed execution.

that option appears to be gnu-specific. -l should make it line-buffered

Note that -l is also an extension, just a BSD one.

The only options in POSIX sed are -e, -f and -n (and -e is usually cargo-culted by people who want -E. -E being a BSD extension enabling extended regular expressions — -r in GNU sed)

Post reply on HN