3 ms·
Here is a rudimentary alerting system I could write quickly in shell and execute on my laptop: while true; do echo ok | nc -l 8000; for i in 1 2 3 4; do prin
by susam 5y ago
Here is a rudimentary alerting system I could write quickly in shell and execute on my laptop:
while true; do echo ok | nc -l 8000; for i in 1 2 3 4; do printf '\a'; sleep 1; done; done
While the above command worked fine on macOS with the default /usr/bin/nc, on Debian 11.2, I had to modify the above command as follows to make it work:
while true; do echo ok | nc -q 1 -l -p 8000; for i in 1 2 3 4; do printf '\a'; sleep 1; done; done
Now anytime someone connects to port 8000 of my system by any means, I will hear 4 beeps! The other party can use whatever client they have to connect to port 8000 of my system, e.g., a web browser, nc HOST 8000, curl HOST:8000, or even, ssh HOST -p 8000, irssi -c HOST -p 8000, etc.
If your port 8000 is already occupied, I recommend port 41327 as an alternative for this alerting service. After all, 41327 reads "ALERT" in leetspeak.
By the way, visit http://susam.net:8000/ http://susam.net:8000/ right now to send me some beeps! :)
- Villodre 5y agoI bet you're having a fun morning with the beeps :-)
- susam 5y agoIndeed I am! HN readers are a fun group. I am receiving beeps almost every second, so I updated my previous shell script to keep a record of the connections netcat receives. Also, converted the beeping loop to a background job, so that the outer netcat loop does not have to wait for the inner beeping loop to complete before handling the next connection. Notice the '&' before the last 'done' in the improved alerting service below: while true; do (echo ok | nc -q 1 -vlp 8000 2>&1; echo; date -u) | tee -a beeper.log; for i in 1 2 3 4; do printf '\a'; sleep 1; done & done Here is a log of the timestamps of the connections received so far: https://gist.github.com/susam/159c7d92659b3185eb0b0d683998a3b7 https://gist.github.com/susam/159c7d92659b3185eb0b0d683998a3...
- CraneWorm 5y agoneat! here's mine: while true; do curl -q --http0.9 http://susam.net:8000/; sleep $(( $RANDOM % 10 )); done
- ddalex 5y ago> This site can’t be reached - REDACTED refused to connect. Am disappointed and my day is ruined
- wwwasdfthrone 5y agoThis sound like a great way to prank someone’s laptop you have access to!
- i2shar 5y agoOn macOS you can replace printf '\a' with something nicer like 'say Lunch time!', or accept a query param and 'say $msg' while true; do echo Coming! | nc -l 8000; for i in 1 2 3 4; do say "Lunch time!"; sleep 1; done; done If you are on the client end of the equation and have ssh access to their mac: ssh user@host say "get your ** here right now"
- samatman 5y agoAlmost anything is less nice than BEL for me, since I've had terminals set to flash-on-BEL for decades.
- TonyTrapp 5y agoIt's essentially the Hacker News Hug of Deaf.
- nirse 5y agoThank you, sending you 4 beeps and seeing that 'ok' was the most web-based fun I had in a very long while!