Any way to execute a piped command in Python using subprocess module, without using shell=True?

后端 未结 4 1415
别跟我提以往
别跟我提以往 2020-12-28 09:27

I want to run a piped command line linux/bash command from Python, which first tars files, and then splits the tar file. The command would look like something this in bash:<

4条回答
  •  天命终不由人
    2020-12-28 09:43

    Shameless plug, I wrote a subprocess wrapper for easier command piping in python: https://github.com/houqp/shell.py

    Example:

    shell.ex("tar -cvf - path_to_archive") | "split -b 20m -d -a 5 - 'archive.tar.split'"
    

提交回复
热议问题