Archive for February 2005

Intelligent FTP upload with LFTP

2005-02-14 17:36

Ever since I started my blog, I was looking for a neat solution to upload my internet pages whenever Nanoblogger updates the local copy.

I didn’t want just a recursive upload, because some directories (e.g. data) shouldn’t be publicly accessible. My first attempt was a script using ncftpput, but it always uploads the whole site.

I wanted a more intelligent solution that copies only new and changed files. This is presumably a very common tasks, there should be plenty of ways to achieve it. But almost all FTP clients capable of intelligent uploads involve some GUI. The only command line client I could find is lftp (available on OS X from Fink and from Darwinports).

So here is my script:

#!/bin/sh
#
# publish a nanoblogger blog

# publishing variables
PUBLISH_HOST="www.your.blog"
PUBLISH_LOGIN="yourlogin"
PUBLISH_PATH="/path/to/your/blog"

PUBLISH_PATTERN="-X * -I archives/ -I images/ -I styles/ -I articles/ -I smilies/"
PUBLISH_PATTERN="$PUBLISH_PATTERN -I *.html -I *.xml -I *.rdf -I *.css -I robots.txt"
PUBLISH_PATTERN="$PUBLISH_PATTERN -I *.png -I *.jpg -I *.gif -I *.ico"

lftp -c "open -u $PUBLISH_LOGIN $PUBLISH_HOST; mirror -v -R $PUBLISH_PATTERN . $PUBLISH_PATH"

Of course you have to adjust the first three variables. The PUBLISH_PATTERN variable should be okay for the current version of Nanoblogger.

CVS with AppleSingle files

2005-02-07 11:07

Longtime Apple developers probably know this intuitively, but I needed some time to figure it out: When CVS-ing files with a resource fork, you must not use the /usr/bin/cvs that ships with OS X!

Because Apple used to separate data and metadata, most files in the pre OS X era had a data fork and a resource fork, but for the user this was transparent; the user just manipulated one file. Tools without this “Classic” background know nothing of the resource fork. Files without data fork appear in the Terminal to have 0 bytes.

CVS is one of these tools that is ignorant of resource forks. For such cases there is the AppleSingle file format (see RFC1740); it is common to put files with a resource fork as AppleSingle file into CVS. To not bother the CVS user, Mac CVS clients like MacCvsPro, MacCvsX or MacCvsClient perform the necessary conversions transparently.

Usually you can accomplish more and have more power on the command line, but in this case it is much easier to use MacCvsPro, MacCvsX or MacCvsClient than the command line. There exist some scripts (applesingle.py and single2forks.pl) to help out command line users, but I was lazy and didn’t try them.