fetch can only download files?

Code:
# fetch -vs 'ftp://ftp.at.freebsd.org/pub/FreeBSD/releases/amd64/8.2-RELEASE/base/*'
looking up ftp.at.freebsd.org
connecting to ftp.at.freebsd.org:21
Unknown

I am successfully using wget, for this task, but wanted to see, if base's fetch, would suffice.

It can't get content of dir, or dir itself, just directly files.
Is this true or am I missing something here?
 
It's not implemented.

Some parts of the library are not yet implemented. The most notable examples of this are fetchPutHTTP(), fetchListHTTP(), fetchListFTP() and FTP proxy support.
From fetch(3)
 
But you still can do what you want:
Code:
#!/bin/sh

parentprime=ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/8.2-RELEASE
mirror=1
distro=src
dest=./$distro

GETFILE() {
	parent=ftp://ftp$mirror.freebsd.org/pub/FreeBSD/releases/i386/8.2-RELEASE
	mirror=`expr $mirror + 1`
	if [ $mirror -gt 4 ] ; then mirror=1 ; fi
#	wget --continue $parent/$distro/$file
	fetch -vrR $parent/$distro/$file
}

if ! [ -w $dest ]; then
	mkdir $dest
fi

if ! [ -r $distro-CHECKSUM.MD5 ]; then
	fetch -o $distro-CHECKSUM.MD5 $parentprime/$distro/CHECKSUM.MD5
fi

cd $dest

while read line
do
	file=`echo $line | awk '{ print $2 }' | sed 's/(//g;s/)//g'`

	if ! [ -f $file ]; then
		GETFILE
	elif ! [ "$line" = "`md5 $file`" ]; then
		GETFILE
	fi
done < ../$distro-CHECKSUM.MD5
Of course this only works with the FreeBSD FTP (for obvious reasons).

If you have any improvements, don't hesitate to share them.
 
Back
Top