[Tutor] untar?

dman dman@dman.ddts.net
Mon, 15 Apr 2002 20:12:08 -0500


On Mon, Apr 15, 2002 at 02:23:28PM -0700, lco wrote:
| I'm running python 2.1c on windows 2000. What I would like to do is make a
| script that can automatically fetch a tar file via ftp and then untar it to
| a specified directory. I've already gotten the ftp function to work but
| unable to find anything on untaring the file. Can someone post for me an
| example of how this can be done? or point me toward the right direction? TIA

I don't know of any tar handlers for python, but if you install
cygwin, this shell script will do the same trick :

~~~~~~~~~~~
#!/bin/bash

URL=$1
if [ -z "$URL" ] ; then
    echo "You need to specify a URL"
    exit 1
fi

wget $URL
tar -zxvf `echo $URL | sed -e 's,http://.*/,,'`
~~~~~~~~~~~


If you think python is better suited for the job, you can use
os.system() to invoke tar, but you'll still have to install cygwin to
get tar.

(oh, yeah, wget supports http too, no extra work required :-))

HTH,
-D

-- 

Consider what God has done:
    Who can straighten what He has made crooked?
        Ecclesiastes 7:13