Monday, April 7, 2008

disget

Sometimes you want to download a certain file (over FTP in this case), but Google doesn't always give an answer. Although simple, this script takes the work out of finding the right files:

distget

#!/bin/sh
MIRROR='ftp://gentoo.osuosl.org/pub/gentoo/distfiles/'

if [[ "$1" != '' ]]; then
wget -O - "$MIRROR" | grep "$1" | awk '{print $6}' | awk -F\" '{print $2}'
fi
% sh distget cow
--2008-04-07 07:54:45-- ftp://gentoo.osuosl.org/pub/gentoo/distfiles/
=> `-'
Resolving gentoo.osuosl.org... 140.211.166.134
Connecting to gentoo.osuosl.org|140.211.166.134|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/gentoo/distfiles ... done.
==> PASV ... done. ==> LIST ... done.

[ <=> ] 2,251,749 730K/s in 3.0s

2008-04-07 07:54:48 (730 KB/s) - `-' saved [2251749]

Removed `.listing'.
Wrote HTML-ized index to `-'.
ftp://gentoo.osuosl.org:21/pub/gentoo/distfiles/cowbell-0.2.7.1.tar.gz
ftp://gentoo.osuosl.org:21/pub/gentoo/distfiles/cowloop-1.4.tar.gz
ftp://gentoo.osuosl.org:21/pub/gentoo/distfiles/cowloop-2.14.tar.gz
ftp://gentoo.osuosl.org:21/pub/gentoo/distfiles/cowloop-2.15.tar.gz
ftp://gentoo.osuosl.org:21/pub/gentoo/distfiles/cowloop-3.0.tar.gz
ftp://gentoo.osuosl.org:21/pub/gentoo/distfiles/cowsay-3.03.tar.gz

No comments: