Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65213
| References | <d06a0b0e-3fb9-4e69-8104-bfe4a556fa0e@googlegroups.com> |
|---|---|
| Date | 2014-02-01 07:40 -0500 |
| Subject | Re: piping with subprocess |
| From | Daniel da Silva <var.mail.daniel@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6277.1391261676.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
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@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
>
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
piping with subprocess Rick Dooling <rpdooling@gmail.com> - 2014-02-01 04:19 -0800
Re: piping with subprocess Peter Otten <__peter__@web.de> - 2014-02-01 13:54 +0100
Re: piping with subprocess Rick Dooling <rpdooling@gmail.com> - 2014-02-01 05:54 -0800
Re: piping with subprocess Rick Dooling <rpdooling@gmail.com> - 2014-02-01 06:00 -0800
Re: piping with subprocess Rick Dooling <rpdooling@gmail.com> - 2014-02-01 07:35 -0800
Re: piping with subprocess Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-01 15:59 +0000
Re: piping with subprocess Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-01 14:28 +0000
Re: piping with subprocess Peter Otten <__peter__@web.de> - 2014-02-01 18:32 +0100
Re: piping with subprocess Daniel da Silva <var.mail.daniel@gmail.com> - 2014-02-01 07:40 -0500
csiph-web