A Fun Little Hack
My favorite hack out of my past is definitely my dynamic '.plan' file. The text-based shells on Unix systems remained the center of most online activity at the university. The '.plan' file is a mundane file that any user may fill with text to be displayed with their user profile. I took this simple facet of the system and turned it into vibrant display, personalized for each user.
Users have the option of editing a file named '.plan' in their home directory. The contents of the file are then displayed when someone uses 'finger' on their account. It is just a plain text file, much like an email signature. The default text provided is, simply, 'No Plan.'
To get an idea of what you might see when using the command 'finger [user]' on a Unix System, the text displayed on your console screen would appear something like this:
Login: msmall Name: Matthew J. Small
Directory: /home/msmall Shell: /bin/bash
On since Mon 30 Sep 21:50 (PDT) on ttyp1 (messages off)
It is a fairly bland and uninspiring canvas as first glance. Then my studies introduced me to the notion of a pipe file. This is a special type of file, whereby both ends of the pipe need to be open for information to flow. A program must be running, attempting to read from the file, while another is running, attempting to write. The information then transfers between the two. If only one side is open, the process will be suspended while it waits.
This pipe concept gave me the inspiration for creating a fully featured dynamic plan on my account. Some obstacles still stand in my way. I must create the special file, replacing the '.plan' file. I must develop a program to write out the data as needed. The first obstacle was easy, a quick program created the properly flagged file. Feeding it the information proved more difficult.
Now, with the pipe file in place, whenever my user information is requested, their console will hang awaiting data from the pipe. Ctrl-C would release the console, but after a few complaints to the system administrator by unknowing users, and the situation needed quick resolution.
Thankfully, there is also a '.project' file, which will display as a single line of text, BEFORE the '.plan' is attempted to be read. Just enough to provide instructions on how to solve the hanging console problem. Now, on to making those instructions unnecessary.
My account on the system is just a lowly user account, with no administrator privileges. I am able to dial-up, log in, and start a background program to wait and write to the pipe. The trouble is once I log out, the program is terminated. Not the best solution, especially with access to only one phone line.
One day an unrelated program I was developing and testing got a little out of control, monopolizing resources on the server and locking up my console. In the process of trying to stop it, before the administrators noticed, I made an important discovery. Working from a friends computer, the slowly responding server eventually allowed me to log in.
I identified my other terminal process, killing it, fully expecting the rampaging program to die. No such luck. I still needed to track it down individually and terminate the processes. That got me wondering if killing my shell would have the same effect of allowing my '.plan' program to continue to run. A quick test proved effective. Now I just need to develop the ultimate '.plan' program.
I began by investigating my options for what characters could be displayed by the 'finger' program. An initial test locked up a Sun Workstation. The character '^G' is known as a bell. It is displayed as an audio beep rather than visually. Apparently, once the workstation read in 3,000 bells, it was set on displaying them. One at a time. A loud one second bell. Echoing in the computer lab. Rebooting the workstations is not allowed, so I left and returned in an hour. I feel bad for the assistant assigned to monitor the lab.
With sound crossed of the list due to practicality, the investigation turned to visual displays. To get insights into the text displays available, I ran the text editor, pico, and mail program, pine, with their output redirected to a text file, rather than displaying on the console screen. Using such a file as my '.plan' provided a nice graphical display with highlighting and flashing text.
After some time studying the characters in the files I was able to decipher the characters for blanking the console screen to provide a clean display, using different text styles, and moving the cursor around. On to the content.
Now my '.plan' is quite visually appealing, but that could have been accomplished with a static file. I figured out that if my program used other system commands, identifying active ports and users, I could determine the user running the finger command to look up my information and where they were doing it from. My program could then look up their user information with the 'finger' command and personalize my '.plan' greeting to them. I also added a counter, along with logging those who viewed my profile.
My '.plan' was viewed by well over 300 different students, as well as teachers and administrators. They combined for well over 2,000 viewings. The popularity of my profile even earned me some change by selling advertising space for a school event.
The '.plan' program ended up embodying much of the concepts behind the modern web. It's uniqueness and mystery captured the curiosity of students campus-wide. Fellow Computer Science marvelled out how a static file came to life.
Version 2 of the '.plan' was to leverage the newly installed ethernet networks across campus and a voice modem, to identify the origin of the 'finger' request by IP address and phone them with a customized message. I just couldn't talk my friend into giving up the database that would allow correlating the IP's and phone numbers. Ah well, it was a fun little hack anyway...
- Story provided by Matthew J. Small, Founder and CEO of Small Chaos -