You normally think of a critical section — that is, a piece of a program that excludes other programs from using a resource — as a pretty advanced technique. You certainly don’t often think of them as part of shell scripting but it turns out they are surprisingly useful for certain scripts. Most often, a critical section is protecting some system resource like a shared memory location, but there are cases where a shell script needs similar protection. Luckily, it is really easy to add critical sections to shell scripts, and I’ll show you how.
Sometimes Scripts Need to Be Selfish
One very common case is where you want a script to run exactly one time. If the same script runs again while the original is active, you want to exit after possibly printing a message. Another common case is when you are updating some file and you need undisturbed access while making the change.
That was actually the case that got me thinking about this. I have a script — may be the subject of a future Linux-Fu — that provides dynamic DNS by altering a configuration file for the DNS server. If two copies of the script run at the same time, it is important that only one of them does modifications. The second copy can run after the first is totally complete.
Continue reading “Linux-Fu: One At A Time, Please! Critical Sections In Bash Scripts”
If you pay attention to airplane news — or you watched the film Sully — you know planes have problems with birds. Sully was about US Airways flight 1549 which struck a flock of geese and ditched in the Hudson river. Engineers at Caltech say that was the inspiration for them to develop a control algorithm that enables a single drone scarecrow to herd flocks of birds away from airports.
Airports have tried a lot of things to discourage birds ranging from trained falcons to manually-piloted drones. Apparently, herding birds is harder than you would think. If you fly the drone too far from a flock, it will ignore the threat. If you get too close, the flock will scatter making it both threaten a larger area and harder to control.
Continue reading “High Tech Drone Scarecrows Can Make Airports Safer”
Many companies today try to simplify life by over complicating the keyboard. Microsoft has been doing it since 2001. If you love your ergonomic keyboard, but hate that “function lock” key, there are plenty of options out there for you to try.
The least complicated way is to either modify some XML or just set macros up in the MS software, but who wants to do that every time they re-install Windows? Reader [Elco] didn’t so he added a simple little 555 circuit inside the keyboard, that automatically re-enables the Flock after three seconds if he happens to hit it during fast and furious typing.
Now no matter what system the keyboard is plugged into he does not have to worry that if he hits F7 whether the system is going to spell check his document, or reply to an email, or that F2 is actually going to rename something and not undo his work silently.