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

Piping external commands

P: n/a

What is the Python translation for this Bash statement:

tar cf - "${files[@]}" | bzip2 "$file".tar.bz2

(Ignoring the fact that "tar cjf" also exists...)

In other words, how does one pipe together arbitrary commands?
Jul 18 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
sa*********@gmail.com wrote:
What is the Python translation for this Bash statement:

tar cf - "${files[@]}" | bzip2 "$file".tar.bz2

(Ignoring the fact that "tar cjf" also exists...)

In other words, how does one pipe together arbitrary commands?
For piping subcommands check out the subprocess module, especially
http://docs.python.org/lib/node242.html , for bzip2 check out the bz2
module http://docs.python.org/lib/module-bz2.html , but note, there's
also a tarfile module http://docs.python.org/lib/module-tarfile.html
which can handle bzip2 as well.

HTH,
~Simon

Jul 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.