Awk driven IoT
anisse.astier.eu
anisse.astier.eu
I really like Awk as a language because it integrates so well with shell pipelines and it is incredibly small, while remaining high-level enough to be practical, which I think this project demonstrates quite well.
[0]: https://web.archive.org/web/20140926113347/http://www.wra1th...
Also, awk syntax is clearly the predecessor of JavaScript. The following is both awk and JavaScript:
function f(x) {
my_array[1] = "whatever"
my_array["a string"] = "something else"
if (x in my_array) return my_array[x]
}
It's all there: the "in" operator, no need for semicolon as statement terminator, the "function" keyword, untypedness, regular expression constants, C-like curly braces, etc.- Awk has no local variables! There is no "var". Believe it or not, people fake locals with unused function parameters.
- Awk has no dict literals like d={}. And no function literals like f = function(x) { return x; }
- Awk dicts can't be nested. You can't have something like: {key1: {key2: 123}} (using JS syntax)
- Awk CAN accept dicts as parameters, but it CAN'T return them. "return d" is invalid.
- Awk can't take functions as parameters OR return them. That is, no higher order functions.
The latter three facts are basically consequences of the fact that Awk has no garbage collection. It has a strict stack discipline and no nested compound data structures.
Citation, please?
It looks like busybox implements the 'dos2unix', 'tac', and 'unix2dos' commands as shell scripts that call 'sed'. And there are a couple of awk scripts (e.g. 'scripts/checkhelp.awk') that are used during the busybox build process. But as far as I can tell, all of the actual busybox applets are written in plain C.
I'd love to be wrong on this point, however -- I think that implementing a full POSIX userspace with just /bin/sh and /bin/awk is an awesome idea!
>It's all there: the "in" operator, no need for semicolon as statement terminator, the "function" keyword, untypedness, regular expression constants, C-like curly braces, etc
At some point, these polyglots must merge. It makes no sense to have arbitrary particles be the only distinction between languages.
Plus, awk is probably in any *nix system, and probably doesn't need any updates to behave as expected. (And my favourite little thing: awk's executable is tiny.)
There's a company who developed a cute product around this type of technology. It's a bestselling toy in Germany.
German here; never heard of it, but looks amazing for my daughter. Thanks for mentioning this!
I wish awk had more mind share than it does these days.
Has anyone started a business where you send in some photos, or sit for a sculptor, then they 3D print a set of NFC caricatures for you? I imagine it would be fairly easy to do, especially if the sculpture tutor at your local art school was willing to help with hiring.
... | while read -r line; do
file=
case "$line" in
*"03 52 c1 1a"*) echo "file1 "; file="file1.mp3" ;;
esac
if test -n "$file"; then
mpg321 -q "$file" &
fi
doneWould be cool to let my 3.5yr old boy play some songs he likes... But at his age, I need to think of a more advanced physical controller or remote (any suggestions?)
... and of course he can press a button :)
Otherwise you'd have to macgyver a toy with giant buttons, build a Bluetooth device onto it that sends a different signal for each button.
In Bryan Cantrill's (paraphrased) words: "let there be an orgy of AWK one-liners!"
(Or even better, entire applications written in AWK, since the language is perfect for dynamically generating web applications.)
The original as referenced here - ftp://minnie.tuhs.org/UnixArchive/Documentation/Books/Life_with_Unix.pdf - is no longer available as "The Independent UNIX Bookstore" no longer exists.
https://www.gnu.org/software/gawk/manual/html_node/Debugger....