I am always downloading files from the command prompt using curl or wget. Sometimes I like to automate the download process. One thing I found to be helpful is using sed to extract the file name from the URL.
I created the following bash script in utilizing my sendmail.pl Perl script found in Why wait for a download?. I called the following script DownloadAndEmailMe.sh. Here it is.
#!/bin/bashOf course there are a few things to change in the script above to make it yours:
curl -O $1
filename=`echo $1 | sed 's/\(.*\)\///'
perl /path/to/sendmail.pl localhost youremail@gmail.com youremail@gmail.com
"Download Done: $filename" "The following file is done downloading: $filename"
1. Change /path/to/sendmail.pl to your own path to sendmail.pl
2. Change localhost to your own SMTP server name.
3. Change youremail@gmail.com to your own email.
This is how I run it
DownloadAndEmailMe.sh http://mirrors.easynews.com/linux/ubuntu-releases/jaunty/ubuntu-9.04-desktop-i386.isoWhen the download is done it will send you a nice email that reads:
The following file is done downloading: ubuntu-9.04-desktop-i386.iso
I would also recommend looking at sed and see how it works. I use it a lot. It's very powerful.