By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,001 Members | 1,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,001 IT Pros & Developers. It's quick & easy.

Using Gnutar to remove a list of files

P: n/a
Hi folks, I've got a question for yas. I'm trying to write code that
will open up a gzipped tar file using gnutar, and copy the list of
files(including their directories) to a list variable in python. From
there, I want to go through the list and delete those files from my
system. That part is easy, but what I'm stuck on is getting the list
of files in an archive into a list variable. If I use the -t parameter
in gnutar, it prints a list of the files in a seperate cmd screen, but
only returns 0. Is there any way to make it return a list, or to copy
the information over? Thanks in advance!

Oct 10 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 2006-10-10 14:35:30 +0200, cm******@uottawa.ca wrote:
Hi folks, I've got a question for yas. I'm trying to write code that
will open up a gzipped tar file using gnutar, and copy the list of
files(including their directories) to a list variable in python. From
there, I want to go through the list and delete those files from my
system. That part is easy, but what I'm stuck on is getting the list
of files in an archive into a list variable. If I use the -t parameter
in gnutar, it prints a list of the files in a seperate cmd screen, but
only returns 0. Is there any way to make it return a list, or to copy
the information over? Thanks in advance!
Use the commands module.
Or tarfile of course.

http://docs.python.org/lib/module-commands.html
http://docs.python.org/lib/module-tarfile.html

Gerrit.
Oct 10 '06 #2

P: n/a
wrote in news:11**********************@m73g2000cwd.googlegr oups.com in
comp.lang.python:
Hi folks, I've got a question for yas. I'm trying to write code that
will open up a gzipped tar file using gnutar, and copy the list of
files(including their directories) to a list variable in python. From
there, I want to go through the list and delete those files from my
system. That part is easy, but what I'm stuck on is getting the list
of files in an archive into a list variable. If I use the -t parameter
in gnutar, it prints a list of the files in a seperate cmd screen, but
only returns 0. Is there any way to make it return a list, or to copy
the information over? Thanks in advance!
Perhaps this will help:

http://docs.python.org/lib/tar-examples.html

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Oct 10 '06 #3

P: n/a
Yeah, I got it working with tarfile. Thanks!

Oct 10 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.