Hello World!

I suspect most of us learned programming in a way that somehow involved the phrase “Hello World.” Or, if you are from my part of the world (Texas), perhaps it was “Howdy World.” The traditional equivalent for embedded systems has been making the LED blink. After all, a lot of systems don’t have a display or maybe they have a little LCD – not very helpful to try to print out a string.

Today, though, a system is about as likely to have a network connection as anything else. Naturally, if you want to run a Linux system with an embedded web server, there are plenty to choose from (including Mongoose, which I’ve talked about a few years ago here).

On the other hand, you might just want to debug something on the fly. You might think writing a web server is a daunting task. If you want to write a robust and secure one it is a pretty big job. But I’m thinking something small, useful, and disposable.

One of the often-overlooked programming languages you have on a Linux-based board is your favorite shell. Many of the shells (including bash) are very full featured and because they run programs, totally extensible by just writing a little C code.

Could you write a web server in bash? You certainly can. A quick Google showed quite a few, in fact. If you really want minimalist, here’s a server in one line: http://is.gd/yb1T7k.

In all fairness, it isn’t just bash, of course. Programs like nc (netcat), but, as I said, you can think of those as extensions to the shell. If you want something a little easier to read, try http://is.gd/kxLUrh or http://is.gd/iDelqp.

Don’t get me wrong. I’m not suggesting you’d actually use these for any real production purpose. But a quick and dirty web server running on a Linux board with very little software required (assuming you have nc, which most of them rely on heavily) can be very helpful in a lot of debugging and testing situations.