bashlib is a shell script that makes CGI programming in the bash shell easier, or at least more tolerable. It contains a few functions that get called automatically and place form elements (from POSTs and GETs) and cookies in your environment. It also contains complete documentation on how to use these variables and how to set cookies manually.
The most recent version of bashlib will always be available from http://bashlib.sourceforge.net/src/bashlib-current.tar.gz and will be browsable at http://bashlib.sourceforge.net/src/bashlib-current/.
Version 0.4 (download or browse) of bashlib, released March 12, 2002, is fully autoconfiscated. To install it, run ./configure
as usual. If you check out the CVS version, you'll need autoconf
installed to create the configure script from configure.in.
I released version 0.3 (download or browse)of bashlib on February 21, 2001. The only difference between 0.3 and 0.2 is that the tarball works. I've been testing it for a while, and it definitely seems stable enough for real use. The interface has changed a little; the sample below reflects these changes.
Things such as this are born of necessity. My ISP, while being incredibly useful in most ways, doesn't have a recent version of Perl available for their casual users (e.g., dial-up accounts, with web pages in http://www.isp.net/~mylogin/) -- Perl is a "value-added" service. This was a great source of frustration for me, since I am a Perl programmer by day. So, I began rooting (not literally) around for other methods of writing CGI scripts, and realized that the shell, which I spent most of my time using, was not only a great generaly purpose scripting environment, but also a good one for CGI scripts. This naturally led me to forms and cookies, and here we are today.
No, I really don't have this much free time. The current release is the result of about a days worth of work (on and off throughout the day), with some help. Well, that's not quite true -- 9 years of using Unix went into it as well.
Using bashlib is pretty straight-forward. More important, however, is knowing what to do with the variables once they come into your script and knowing how to write CGI scripts. (This script is not running here, for obvious reasons.)
#!/bin/bash # this sources bashlib into your current environment . /usr/local/lib/bashlib echo "Content-type: text/html" echo "" # OK, so we've sent the header... now send some content echo "<html><title>Crack This Server</title><body>" # print a "hello" if the username is filled out username=`param username` if [ -n "x$username" != "x" ] ; then echo "<h1>Hello, $username</h1> fi echo "<h2>Users on `/bin/hostname`</h2>" echo "<ul>" # for each user in the passwd file, print their login and full name # bold them if they are the current user for user in $(cat /etc/passwd | awk -F: '{print $1 "\t" $5}') ; do echo "<li>" if [ "$username" = "$user" ] ; then echo "<strong>$user</strong>" else echo "$user" fi echo "</li>" done echo "</ul>" echo "</body></html>"
Bashish is a theme engine for the console.
It lets you customize title, prompt, background, foreground, colors, font and a lot of other things.
Bashish is also very configurable, you can turn on and off nearly all features.
Surfraw (Shell Users' Revolutionary Front Rage Against the Web) provides a Unix command line interface to a variety of popular Web search engines and sites, including Google, Altavista, Babelfish, Raging, DejaNews, Research Index, Yahoo!, WeatherNews, Slashdot, freshmeat, and many others.
OK, so there's probably something in here you think should be different, could be better, etc. Well, drop me a line (email me at dlc@users.sourceforge.net) and let me know. You can write it out in words ("bashlib should uuencode GIFs on the fly"), provide a patch (via diff -u), or rewrite the whole thing (try to keep it in shell, though). All reasonable emails will be read, and probably answered as well.
bashlib is a pretty short script (as libraries go), and all versions can be browsed here. It is available for download from Sourceforge at http.
bashlib is also available from anonymous CVS. The CVS repository can be checked out through anonymous (pserver) CVS. When prompted for a password for anonymous, simply press the Enter key.
cvs -d:pserver:anonymous@cvs.bashlib.sourceforge.net:/cvsroot/bashlib login cvs -z3 -d:pserver:anonymous@cvs.bashlib.sourceforge.net:/cvsroot/bashlib co bashlib