#!/bin/sh
if [ -z "$1" -o "$1" = "-h" ]; then
cat << HELPMSG
ftpfiles -- quickly fetch some html files from the server
USAGE: ftpfiles [-h] path_to_directory|.
EXAMPLE: ftpfiles English/February2005
This will fetch all files ending in *html from the English/February2005
directory on the server and save them localy in the current directory.
Local files are not overwritten if they are more recent than the files
on the server.
EXAMPLE: ftpfiles .
This will run pwd to get the current directory and then take the last
two components from this. If you are e.g in a directory called
/home/linuxfocus/Deutsch/November2004 then it will get *html files from
Deutsch/November2004 on the server.
Local files are not overwritten if they are more recent than the files
on the server.
HELPMSG
exit 0
fi
if [ "$1" = "." ]; then
dir=`pwd | perl -ne 'if (m=^.*/([A-Z][a-z]+)/([A-Z][a-z]+[0-9]+)=){print "$1/$2";}'`
if [ -z "$dir" ]; then
echo "ERROR: you are not in a subdirectory of an issue"
exit 1
fi
else
dir=`echo "$1" | sed -e s=/$==`
fi
echo "fetching files from $dir ..."
echo ""
echo ""
wget -g on -nd -N --passive-ftp "ftp://linuxfocus.org/pub/lf/$dir/*html"