June 6, 2004 10:35 AM
I have to admit, the first time I visited aloof, I laughed a
lot. Surely, this is the first professional website that interfaces
humor with free web hosting. The bandwidth and space they offer is
unmatched compared to any other host. The only down point was no CGI
scripting. Hey, with 250 MB web space and large bandwidth, who's
complaining? Even their forums are a riot.
Being familiar with ftp1 and elisp, automating publishing to the
aloof ftp server by integrating it into the blog module I wrote for
emacs-wiki was a cinch. Sad that there seems to be no equivalent for
the newer [local-file-name] for a put in ftp. My work around
involves using the tar -N .publish-stamp to transfer all new files
to a temporary directory and then
cat ftpcommands | ftp -nv
where ftpcommands is a file containing commands for ftp such as open,
mput, user, etc. But, the million dollar question is, "Is this the
most elegant way of scripting a ftp transfer?"
Here's the elisp code I came up with:
(defun ani-publish-to-temp () "Extract new files to tmp/publish based on publish-stamp" (interactive) (shell-command (concat "cd /home/anirudh/public_html && (" "tar -N .publish-stamp --exclude='./.*' --exclude='*~'" " -cvf - *.*ml *.css blog/*.*ml imgs/* code/*.*ml | " "(cd /home/anirudh/tmp/publish && tar -xf -)) 2> .tarlog"))) (defun ani-publish-to-ftp () "Publish from tmp/publish to ftp server" (interactive) (shell-command (concat "touch .publish-stamp;" "cat ~/scripts/ftpcommands | ftp -nv &")))
.publish-stamp is a 0 byte file created with the touch
command. The functions above are called automatically after
emacs-wiki-publish is called by re-defining the key assignment to
C-c C-p. Below are the contents of the file ftpcommands:
prompt open ftp.aloofhosting.com 21 user xxxx xxxx ascii lcd /home/anirudh/tmp/publish mput * disconnect quit
The above file and code has been rather simplified to illustrate my point.
[1] /usr/bin/ftp utility in Linux. It originally appeared in 4.2BSD.