<div dir="ltr"><div><span style="font-family:arial,sans-serif">Try this:</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">from subprocess import check_output</span><br>
</div><div><font face="arial, sans-serif">import sys</font></div><div>check_output("<span style="font-family:arial,sans-serif;font-size:13px">textutil -convert html %s -stdout | pandoc -f html -t markdown -o %s" % sys.argv[1:3], shell=True)</span></div>
<div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Feb 1, 2014 at 7:19 AM, Rick Dooling <span dir="ltr"><<a href="mailto:rpdooling@gmail.com" target="_blank">rpdooling@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I spent half a day trying to convert this bash script (on Mac)<br>
<br>
textutil -convert html $1 -stdout | pandoc -f html -t markdown -o $2<br>
<br>
into Python using subprocess pipes.<br>
<br>
It works if I save the above into a shell script called convert.sh and then do<br>
<br>
subprocess.check_call(["convert.sh", file, markdown_file])<br>
<br>
where file and markdown_file are variables.<br>
<br>
But otherwise my piping attempts fail.<br>
<br>
Could someone show me how to pipe in subprocess. Yes, I've read the doc, especially<br>
<br>
<a href="http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline" target="_blank">http://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline</a><br>
<br>
But I'm a feeble hobbyist, not a computer scientist.<br>
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888"><br>
RD<br>
--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>