Piping external commands

Discussion in 'Python' started by saibotorama@gmail.com, Jul 18, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Simon Forman Guest

    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
     
    Simon Forman, Jul 18, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Pfaff

    Re: man pages for C commands (GCC commands)

    Ben Pfaff, Jun 24, 2003, in forum: C Programming
    Replies:
    4
    Views:
    3,977
    Thomas Stegen
    Jun 28, 2003
  2. Thomas Kellerer
    Replies:
    47
    Views:
    1,512
    Martin Gregorie
    Apr 12, 2009
  3. Tim Arnold

    piping input to an external script

    Tim Arnold, May 11, 2009, in forum: Python
    Replies:
    9
    Views:
    318
    Steve Howell
    May 12, 2009
  4. |MKSM|
    Replies:
    1
    Views:
    126
    Robert Klemme
    Mar 6, 2006
  5. Hans Fugal

    Piping two shell commands together

    Hans Fugal, Aug 2, 2007, in forum: Ruby
    Replies:
    7
    Views:
    103
    Hans Fugal
    Aug 4, 2007
Loading...

Share This Page