curl-users
For Unix/Linux/Cygwin users - bash script for downloading
Date: Mon, 01 Mar 2010 11:15:09 -0500
I'm not exactly sure what the practice or policy is regarding
attachments, but as I've seen status reports and whatnot pasted into
messages to the list, I will do so for this script and leave it to those
who want to use it to copy and edit.
SJ Wright
#!/bin/bash
#readycurl.sh -- A script to keep the 'curl -o' option handy
#when downloading from several sites or servers.
#Tested and working with:
#curl 7.20.0 (i686-pc-cygwin) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
libidn/1.16 libssh2/1.2.2
#(ymmv)
logtime=$(date "+%d.%m.%Y-%H.%M")
logname="curlactivity-$logtime.log"
touch $logname
echo -ne "Log started at `date "+%d.%m.%Y @ %H:%M:%S"`.\n\n">>$logname
while true
do
echo -ne "What is your file to be called?\n"
read theName
if [ $theName != "done" ]
then
thisFile=$theName
echo -ne "Where is the file?\n"
read thisSource
dimple=$(echo ${thisSource:0:5})
if [ $dimple != "http:" ]
then
echo -ne "I'm exiting.\n" && break
else
GRABTIME=$(date "+%d.%m.%Y @ %H:%M:%S")
thisPlace=`echo $thisSource | rev | cut -d / -f2- | rev`
thisName=`echo ${thisSource##*/}`
if [ -f $logname ]; then
curl -o "$thisFile" "$thisSource" && echo -ne "$GRABTIME":
"$thisFile" came from "$thisPlace/" and was called "$thisName\n">> $logname
fi
fi
else
echo -ne "Alright. I quit!\n" && break
fi
done
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-01