Version 2 (modified by danny_adair, 15 years ago) ( diff )

--

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"
Note: See TracWiki for help on using the wiki.
Back to Top