Ken Thompson and Dennis Ritchie, overlook the PDP-11.

$man bot: homage to Thompson and Ritchie and the Linux man pages

A departure from my first, and revamped Twitter bot, I was inspired at work to create a more functional bot, one tweeting daily, the pages of the Linux Programmer’s Manual.

Linux Programmers Manual

Linux Programmers Manual

The bot came about through my colleague’s extended use of Linux in an environment where it has previously proven difficult to use it – the civil service.

It came about through a continuing appreciation of how cool Linux really is; how useful it is in our work; and further, the unintentional, but rather ridiculous ‘gender specification‘ that occurs when one looks up a function within the Linux environment: $man <command name> A specification that creates a curious and often humorous juxtaposition:

It is therefore a conscious attempt at subverting the concept of gender role, but notably, it is also a conscious, and serious attempt to introduce all users to the simplicity and accessibility of the Linux environment.

The concept of this bot is simple, to tweet a single* command daily. Alongside the command is a link to a manual page; approximating the act of typing the command into a Linux terminal and subtly hinting to users to experiment by doing the same for themselves.

Attempts were made to find methods of accessing the manual in different ways, e.g. emulation, but in the end a suitable and minimalist web resource was selected in http://man7.org/linux/man-pages/.

The index was scraped and reorganized into a comma separated values (CSV) spreadsheet that could be used as a source for randomized tweets. While this could be done automatically via script, I elected to do this by hand for this first attempt. If I update the source in a few months, or a few years, then I will consider a scripted mechanism.

From there it was a matter of taking my code already utilizing the Python sixohsix twitter API libraries and enabling it to tweet from a new account.  The primary function sits here: https://github.com/exponential-decay/manpage-du-jour/blob/master/manpage-du-jour.py#L55 it’s a little simplistic, and could easily be improved to make better use of constants and to improve clarity.

The function needs to grab the command name, the command description, and the relative path from the CSV and generate an absolute reference. URLs are always shortened to 22 characters in a tweet and so the code also has to honor that and a 140 character limit when formatting, before submitting to the server:

$ man <command name>: <description> <hyperlink> #linux #manpage

<POST>

And it’s done. A twitter bot, a learning resource, a source of humor, and a source of gender subversion; an entity that should still be around when twitter itself becomes post-apocalyptic. Roaming in a vast desert of spam bots, education bots, random bots, and all manners of grey-goo.

There isn’t a lot more to discuss in the detail but I’m open to receive questions about the code. This blog entry is as much about promotion for this resource; your sharing of it with colleagues and friends interested in programming, Linux, computing history, or just computing in general is appreciated. Thank you in advance for following.

Source code and more information can be found on GitHub: https://github.com/exponential-decay/manpage-du-jour

*Because there is such a vast number of Linux commands (6494 in the source data available to me at the time of writing) I decided to tweet twice in a single go. Ideally I would use a cron job to tweet, maybe three times; three random tweets to capture the broadest range of time zones each day.