Linux Voyager: sed and awk and bash, oh my!
Morning weigh-in: 176#, 13.5% BF
OK, so I haven't played with awk yet, but I'm starting to look at sed, and I'm getting a little deeper into scripting with bash. The context, of course, is still that script to take a bunch of JPEG files and generate a photo gallery for them.
Right now the script creates a directory called "html" in the working directory, and one called "photos" (with a "thumbs" subdirectory) there as well, then for each jpg/JPG file in the working directory it makes a smaller, thumbnail version of the file in "photos/thumbs", moves the file itself to "photos", and generates an HTML file in "html" to display the original file. It also makes an HTML file in the working directory to serve as an index, which displays the thumbs as links to the display files. The display files have links to each other -- "next" and "previous" display files, as defined by their order in the index -- as well as a link back to the index.
I used this to make my "Photos of Mike" Gallery, which shows how the resulting pages work together. (The explanatory text on the display pages was put in with an ordinary HTML editor; this text, and the linking structure on the display pages, are why I used HTML instead of just displaying the photos. If you look at the navigation links on the bash vs the awk pages you'll see why I thought my link structure was a good idea.)
My problems with the script as it stands are mostly related to its lack of flexibility. I'd like to have more control over the photo file selection, and maybe have the index and page display files be written from templates; I may also make a lot more of the "hardwired" stuff be variables, with default variables that can be superseded by a configuration file. These can all be command line arguments, options etc, and the configuration file could be just another shell script, but the templates may be tricky... hence, sed and awk.
In the long run, it may be easier to just port this to perl, but in the even longer run, an entirely new web page structure, based on CGI or CSS, may be the smarter move. (I spent some time experimenting with forms last night.)
No comments:
Post a Comment