[Techtalk] download_script.php with wget
Conor Daly
c.daly at met.ie
Tue Jan 11 22:11:58 EST 2005
On Tue, Jan 11, 2005 at 10:21:09AM +0000 or thereabouts, Conor Daly wrote:
>
> # lynx --dump http://www.vim.org/scripts/download_script.php?src_id=3576 > test.zip
I've put together a little something to use lynx to correctly download such
files. It's called phpget.sh and I'll put it up on
http://www.cod.utvinternet.com soonish but, in the meantime, here it is:
################## cut here ###############################################################
#!/bin/bash
#####################################
#
# phpget.sh
#
# A script to download files from URLS of the form
#
# http://example.com/download.php?id=nnnn
#
# and to save them with their proper names.
#
# uses lynx -cmd_script <URL>
#
# Useage: phpget.sh <URL>
#
# Author: Conor Daly
# License: GPL
# Date: 11-jan-2005
#
#####################################
BINDIR=`dirname $0`
LYNXSCRIPT=$BINDIR/cmdfile.lynx
useage() {
cat << USE
Useage: $0 [ install ] <URL>
A script to download files from URLS of the form
http://example.com/download.php?id=nnnn
and to save them with their proper names.
The 'install' option will generate the response script
for lynx
Author: Conor Daly <conor.daly at met.ie>
License: GPL
Date: 11-jan-2005
USE
}
install() {
cat << CMDFILE
# Command script for lynx for automatic downloading of
# http://example.com/download.php?id=nnnn
# style URLS
# Author: Conor Daly
key d
key Down Arrow
key Right Arrow
key ^J
# Overwrites an existing file
#key y
key q
key ^J
CMDFILE
}
if [ $# -lt 1 ]; then
useage
exit 1
fi
if [ "$1" == "install" ]; then
install > $LYNXSCRIPT
shift
fi
[ $# -gt 0 ] || exit
URL=$1
LYNXBIN=`which lynx`
if [ ! $LYNXBIN ]; then
echo "Error: lynx not found"
exit 1
fi
$LYNXBIN -cmd_script=$LYNXSCRIPT $URL
STATUS=$?
if [ $STATUS -ne 0 ]; then
echo "download failed"
exit $STATUS
fi
################## cut here ###############################################################
Save as phpget.sh and make executable
Conor
--
Conor Daly, Please avoid sending me
Met Eireann, Glasnevin Hill, Word or PowerPoint attachments.
Dublin 9, Ireland http://www.fsf.org/philosophy/no-word-attachments.html
Ph +3531 8064276 Fax +3531 8064247
**********************************************************************
This e-mail and any files transmitted with it are confidential
and intended solely for the addressee. If you have received
this email in error please notify the sender.
This e-mail message has also been scanned for the
presence of computer viruses.
**********************************************************************
More information about the Techtalk
mailing list