调用tar命令 [英] calling tar commands

查看:84
本文介绍了调用tar命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为我想要做的事情是非常基本的,但我是一个初学者,我被困住了。我在WindowsNT上使用Python 2.4.1。我安装了UnxUtils,其中包含Windows的tar命令。


直接目标:

我有一个包含tar文件列表的文本文件,一个每行文件名。现在我只是试图遍历我的文本文件并解压缩列表中的每个文件。


背景/大图:

最终我想要

?循环遍历列表并解压每个tar文件(总共~1700个文件),

?将原始tar文件的一些未涂焦的组件导入图像处理程序(ERDAS Imagine),

?压缩Imagine的输出,

?从原始tar中删除不需要的文件。


到目前为止,我能够遍历列表并打印文件名。此外,tar命令正在从命令行(和批处理文件)工作,但当我尝试将tar命令集成到python上时,我错过了一些东西。


这是我到目前为止所得到的:


#####循环并打印每一行(工作正常) :

I think what I?m trying to do is very basic but I?m a rank beginner and I?m stuck. I?m using Python 2.4.1 on WindowsNT. I?ve installed UnxUtils, which includes the tar commands for Windows.

Immediate objective:
I have a text file containing a list of tar files, one filename per line. For now I?m just trying to loop through my text file and untar each file in the list.

Background/big picture:
Ultimately I?d like to
? Loop through the list and untar each tar file (~1700 files total),
? import some of the un-tarred components of the original tar file into an image processing program (ERDAS Imagine),
? zip the output from Imagine, and
? delete the unneeded files from the original tar.

So far, I?m able to loop through the list and print filenames. Also, the tar command is working from the command line (and batch file) but I?m missing something when I try to integrate the tar command onto python.

Here?s what I?ve got so far:

#####Loop through and print each line (works fine):

展开 | 选择 | Wrap | 行号

推荐答案


我想我是什么我试图这样做是非常基本的,但我是初学者,而且我被困了。我在WindowsNT上使用Python 2.4.1。我安装了UnxUtils,其中包含Windows的tar命令。


直接目标:

我有一个包含tar文件列表的文本文件,一个每行文件名。现在我只是试图遍历我的文本文件并解压缩列表中的每个文件。


背景/大图:

最终我想要

?循环遍历列表并解压每个tar文件(总共~1700个文件),

?将原始tar文件的一些未涂焦的组件导入图像处理程序(ERDAS Imagine),

?压缩Imagine的输出,

?从原始tar中删除不需要的文件。


到目前为止,我能够遍历列表并打印文件名。此外,tar命令正在从命令行(和批处理文件)工作,但当我尝试将tar命令集成到python上时,我错过了一些东西。


这是我到目前为止所得到的:


#####循环并打印每一行(工作正常) :
I think what I?m trying to do is very basic but I?m a rank beginner and I?m stuck. I?m using Python 2.4.1 on WindowsNT. I?ve installed UnxUtils, which includes the tar commands for Windows.

Immediate objective:
I have a text file containing a list of tar files, one filename per line. For now I?m just trying to loop through my text file and untar each file in the list.

Background/big picture:
Ultimately I?d like to
? Loop through the list and untar each tar file (~1700 files total),
? import some of the un-tarred components of the original tar file into an image processing program (ERDAS Imagine),
? zip the output from Imagine, and
? delete the unneeded files from the original tar.

So far, I?m able to loop through the list and print filenames. Also, the tar command is working from the command line (and batch file) but I?m missing something when I try to integrate the tar command onto python.

Here?s what I?ve got so far:

#####Loop through and print each line (works fine):
展开 | 选择 | Wrap | 行号



我想我想做的是非常基本,但我是初学者,我被困了。我在WindowsNT上使用Python 2.4.1。我安装了UnxUtils,其中包含Windows的tar命令。


直接目标:

我有一个包含tar文件列表的文本文件,一个每行文件名。现在我只是试图遍历我的文本文件并解压缩列表中的每个文件。


背景/大图:

最终我想要

?循环遍历列表并解压每个tar文件(总共~1700个文件),

?将原始tar文件的一些未涂焦的组件导入图像处理程序(ERDAS Imagine),

?压缩Imagine的输出,

?从原始tar中删除不需要的文件。


到目前为止,我能够遍历列表并打印文件名。此外,tar命令正在从命令行(和批处理文件)工作,但当我尝试将tar命令集成到python上时,我错过了一些东西。


这是我到目前为止所得到的:


#####循环并打印每一行(工作正常) :
I think what I?m trying to do is very basic but I?m a rank beginner and I?m stuck. I?m using Python 2.4.1 on WindowsNT. I?ve installed UnxUtils, which includes the tar commands for Windows.

Immediate objective:
I have a text file containing a list of tar files, one filename per line. For now I?m just trying to loop through my text file and untar each file in the list.

Background/big picture:
Ultimately I?d like to
? Loop through the list and untar each tar file (~1700 files total),
? import some of the un-tarred components of the original tar file into an image processing program (ERDAS Imagine),
? zip the output from Imagine, and
? delete the unneeded files from the original tar.

So far, I?m able to loop through the list and print filenames. Also, the tar command is working from the command line (and batch file) but I?m missing something when I try to integrate the tar command onto python.

Here?s what I?ve got so far:

#####Loop through and print each line (works fine):
展开 | 选择 | Wrap | 行号



extractall()接受参数...
extractall() takes in arguments...



是的,但他们是可选的。如果未给出路径,则使用当前目录。

Yea but they''re optional. If a path is not given, it uses the current directory.


这篇关于调用tar命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆