piping with subprocess

Daniel da Silva var.mail.daniel at gmail.com
Sat Feb 1 07:40:58 EST 2014


Try this:

from subprocess import check_output
import sys
check_output("textutil -convert html %s -stdout | pandoc -f html -t
markdown -o %s" % sys.argv[1:3], shell=True)




On Sat, Feb 1, 2014 at 7:19 AM, Rick Dooling <rpdooling at gmail.com> wrote:

> I spent half a day trying to convert this bash script (on Mac)
>
> textutil -convert html $1 -stdout | pandoc -f html -t markdown -o $2
>
> into Python using subprocess pipes.
>
> It works if I save the above into a shell script called convert.sh and
> then do
>
> subprocess.check_call(["convert.sh", file, markdown_file])
>
> where file and markdown_file are variables.
>
> But otherwise my piping attempts fail.
>
> Could someone show me how to pipe in subprocess. Yes, I've read the doc,
> especially
>
> http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline
>
> But I'm a feeble hobbyist, not a computer scientist.
>
> Thanks
>
> RD
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140201/5c7ccdb6/attachment.html>


More information about the Python-list mailing list