A bash script to fetch files from the Django website.

Example usage:

cd ~/mytemplates
djget http://code.djangoproject.com/browser/djangoproject.com/django_website/templates/base_community.html

This fetches the named file and puts it in the current directory with the basename which, in this case, is base_community.html.

Here is the script:

#! /bin/bash
filename=$1
filebasename=`basename ${filename}`
wgetfilename=${filename}?format=txt
wget ${wgetfilename}
if [ $? = 0 ]; then
    mv ${filebasename}?format=txt ${filebasename}
else
    echo wget failed for ${filename}
fi

Comment: You could just use wget's "-O" parameter to specify the output file directly, the script could be a one-liner

wget -O `basename $1` "$1?format=txt"
Last modified 14 years ago Last modified on Feb 2, 2010, 12:30:46 AM
Note: See TracWiki for help on using the wiki.
Back to Top