Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Piping external commands (http://www.velocityreviews.com/forums/t359783-piping-external-commands.html)

saibotorama@gmail.com 07-18-2006 12:46 AM

Piping external commands
 

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?

Simon Forman 07-18-2006 05:43 PM

Re: Piping external commands
 
saibotorama@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



All times are GMT. The time now is 10:44 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.