To UNIX and Back (Alive):
A Primer on Self-service Mailbots and Forms
I just got this far a moment ago and the power went out, blacking out my system and forcing me to start over. So it goes. A long day, beginning in the wee hours, in which I set out to master forms, cgi scripts, mailbots, aliases...in fact I've gotten sucked into a whirlpool of learning over the last three days, into the old-fashioned, arcane world of UNIX, the dreaded terminal interface.
I can't say I came out with mastery of it all, or even much competence; but I came back alive. In fact, I managed to cobble together a working mailbot along the way, and a half-dozen options for forms for my website. So, the decent thing to do is to share some of what I learned, by the grace of a few dark hours and the generosity of other computer fanatics who are evidently far more dedicated or stubborn or quick-minded than I.
Mailbots, or e-mail autoresponders, can be had from commercial servers for as little as ten bucks a month. They are useful for disseminating broad-range feelers about one's product or service or whatever, encouraging interested parties to click "reply" and then responding automatically with a longer text message. Spam for those who like the taste, why not. Marcia Yudkin had a little advice somewhere that I stashed aside about six months back, about designing and installing your own for free in ten minutes; so I dredged up her file and set to work. Three days and nights later...
Well it's a longer story because I've also been sitting on several dozen files and programs about forms--waiting to experiment with all this stuff until I got my recent local phone line. So now was the time. To make a long story short, it wasn't quite necessary to learn all of Perl, CGI, UNIX, Pine, Mail, etc. etc., but it did seem prudent to scan the topic well enough to be able to a) make the supposedly simple mailbot work and b) choose a good method of installing some forms to my website.
Trouble is, the cheap way usually costs time if not money. If you like spending the time, you're laughing. I guess I do. I think this whole computer business was invented to make ourselves feel clever when we figure some of it out. A gigantic, ever-complexifying puzzle, game, maze. At any rate, the mailbot: My server has provided me with a low-cost account and so can only afford scanty help for such tasks. I'm thankful they provide the facilities and a few tips. The facilities include a UNIX platform available via Telnet, a web host available via FTP, and some decent FAQ's. So I got some basics and here they are:
- Get a ready-made, simple mailbot script: mailbot.pl. It's written in Perl which doesn't have to be a problem except...
- You probably have to track down the location of the "sendmail" and "mail" directories on your server's UNIX system in order to get the values just right in the script.
- You need a way to activate it. In Marcia Yudkin's case, it was a "vacation" program on her UNIX server; in my case, it was creating a file called ".forward" that tells incoming mail to go to the mailbot program and to send your desired message text back out. All that happens in one line of the .forward file: with a couple of big ifs...
- The mailbot.pl script has to be installed in a personal cgi-bin directory. And the message.txt has to be in the right place. And, what was hanging me up for the longest time, the UNIX system has to be set to give these files and directories the proper "permissions" with a "chmod" command (mine worked with the value 755). And I thought I could make this summary short and sweet...
- The line in the .forward file has to be formatted correctly. I still haven't figured out the perfect way but what I finally did worked (somewhere between my server's generic description and the mailbot.pl's remarks about what to use).
As a side effect of all this I did become, let us say, passingly acquainted with UNIX and Perl, and it's funny, though I'm not going to spend time learning any more of it than I need to, I did kind of enjoy in a nostalgic way the direct computer-human relationship, something that was so magical at my first encounter in 1968 at Dartmouth's Kiewit Computing Center, where time-sharing through multiple terminals and the use of the programming language BASIC were pioneering concepts...
Where was I? Oh, yes,
Tired of all this plain text yet? Too bad, I haven't got around to Java or animated applets and plug-ins and shockwaves and web-bots and all, just yet. First the basics. My crash course in Perl and CGI scripts seemed like a bit of overkill when I had Microsoft Front Page sitting there with its web-bots waiting to take me down the yellow brick road to programless heaven. Somehow I didn't (still don't) trust the little buggers. This business about loading the "server extensions" up with my website...how much space will they take there, and how reliable? Well, the computer in my Toyota's doing a pretty good job so far...Where was I? Ah, the basics. Basically, it boils down to this:
- Spend a hundred bucks or two on Front Page and forget the rest (if you can).
- Buy a Professional Version of WebForms 2.1 (for $40) and forget the rest (if you can). This software will even process your data direct from the server, by handling your e-mail and sorting it into database tables.
- Use a ready-made CGI script like the one my server has in its main CGI-bin (it's called CGIemail) which will give your client immediate feedback after submitting the form and will send that feedback nicely formatted to your e-mail. The install procedure once again wasn't as straightforward as advertised: it took some experimenting to get the required message file in the right directory, with the right path, and the right permissions.
- The same thing can be done with any number of freely available CGI scripts floating around out there, though again to get the path statements and permissions right is critical. Just play with the directories and chmod values until it works. (It will work, in the end; that's the beauty of it all, that's why we stay up all night at this stuff, right, so at last we can smile and breathe and walk outdoors and go to our lonely mates and say, "I finally got it!")
- Finally (I discovered this one last, wading too far too fast out to the deep water) there's the simple way: just post your form (in the ACTION command) to your mailto: address. Now, simplicity comes with a small price: your mail message will have all the feedback from the form strung out in a single line with the good stuff all gummed up with three-symbol codes for punctuation and spacing. Fortunately there are solutions to apply at the home end of things to straighten this out and give you output that matches what the fancy Perl scripts do...
- Make a search-and-replace (read destroy) macro for your word-processor to change the garbage signs back to real punctuation and spacing. Details courtesy of Harry Sklar...
- Use a nifty little subroutine of a vast and truly intimidating DOS do-it-yourself programming machine called Parse-O-Matic. Another one of those zip files I tried nine months ago and put away for a long winter's night... Actually you don't even have to learn any of it, thanks to the add-on called CVTFREP.POM, which automates this one of a thousand functions you'll want Mr. POM to do for you. Again the output is neat and clean. Choose this if you don't want to get your hands dirty with macros; Go back one space if you don't want to sit at the same desktop with DOS.
Moral? Who said anything about...?
Well, I did save the $125./hr. (four-hour minimum) that my server's technicians would have charged for all this; or the monthly charges of a more full-service outfit. Sort of like, do you change your own oil and spark plugs?
--Funny, I've stopped doing that these last couple of years. At any rate, time to sign off now; gotta go make a big batch of tofu....
© Nowick Gray