Tue, 10 Mar 2009
Automated Blog Posting With Pyblosxom
As some naysayers in #wuglug this (Sunday) evening suggested after three blog posts in a two hour span, I'm going to start posting to my blog once a day automatically, unless I really, really want to get around this. This should be posted Tuesday morning at 6am (famous last words).
I'm using PyBlosxom as my blogging engine, which is essentially based around dropping files into a directory. As such, it's almost trivial to write a script that will do the moving into place which can then be automated by cron. As it's only almost trivial, here's my script:
#!/bin/sh
set -e
set -u
FROMDIR=/home/daniel/pending-blogposts
TODIR=/home/daniel/test
next_post=`ls -t $FROMDIR | tail -n1`
if [ z != z$next_post ]; then
echo $TODIR/$next_post
if [ -e $TODIR/$next_post ]; then
echo "Already a post with that name."
exit 1
else
echo "Posting '$next_post'"
mv $FROMDIR/$next_post $TODIR
touch $TODIR/$next_post
fi
fi
Just change FROMDIR and TODIR to match your needs, drop the resulting script somewhere on your server and add something like
0 6 * * * /home/daniel/bin/blog-postto your crontab and you should be away.
Posted: Tue, 10 Mar 2009 12:21 | Comments: 2