Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'sys': 0.07; '%s"': 0.09; 'bash': 0.09; 'variables.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'sat,': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'trying': 0.19; 'file,': 0.19; 'feb': 0.22; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; "i've": 0.25; 'script': 0.25; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'especially': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; '(on': 0.31; 'pipe': 0.31; 'file': 0.32; 'url:python': 0.33; 'could': 0.34; 'subject:with': 0.35; 'skip:s 30': 0.35; 'convert': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'half': 0.37; 'url:library': 0.38; 'called': 0.40; 'url:mail': 0.40; 'how': 0.40; 'read': 0.60; 'save': 0.62; 'show': 0.63; 'to:addr:gmail.com': 0.65; 'day': 0.76; 'fail.': 0.84; 'piping': 0.84; 'rick': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=7dKLYI5ZKLSksr9dSnZ428XYxuTwhtKIXLYiy0px1TU=; b=MOjfZ5mYmTBETZ8OVYFnpX/sUmFzUbzR+0UvbZAffDX3nv/PcnvXkZZe0zxLgIMBwP q+SExVzF0oHmzd7/Aq3t1HE77WYkdPVPc30qvJIV8AFzQOIVooVdDCnMRfp0LLtkSnIE /IofO7wkgrq8t1Fd+671w5snO+NUlGR++veMMtBrfHfPUEFlDIkpKc7/KatKLuTvoXW1 hx9YpvuI7DbKl7wFO7UtsLG9rXmlKFKMLWN/t/Y0oepiT3vzAA/YjIKwvekQ/oJMMNLD 7OdCmPoJxgELZxMq6HKMu8lgykfyUnbSLbr7ASVn58vYJpheeDMCipfzbwYouyznN/sH KQdg== MIME-Version: 1.0 X-Received: by 10.180.11.36 with SMTP id n4mr2509951wib.4.1391258458912; Sat, 01 Feb 2014 04:40:58 -0800 (PST) Sender: meltingwax@gmail.com In-Reply-To: References: Date: Sat, 1 Feb 2014 07:40:58 -0500 X-Google-Sender-Auth: YAQqSlKR5dvoL9NQs7Eyn6BX4ns Subject: Re: piping with subprocess From: Daniel da Silva To: Rick Dooling Content-Type: multipart/alternative; boundary=001a11c258f03bfc8b04f1579a13 X-Mailman-Approved-At: Sat, 01 Feb 2014 14:34:34 +0100 Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 96 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391261677 news.xs4all.nl 2927 [2001:888:2000:d::a6]:35618 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65213 --001a11c258f03bfc8b04f1579a13 Content-Type: text/plain; charset=ISO-8859-1 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 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 > --001a11c258f03bfc8b04f1579a13 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Try this= :

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




On Sat, Feb 1, 2014= at 7:19 AM, Rick Dooling <rpdooling@gmail.com> wrote:
I spent half a day trying to convert this ba= sh 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.ht= ml#replacing-shell-pipeline

But I'm a feeble hobbyist, not a computer scientist.

Thanks

RD
--
https://mail.python.org/mailman/listinfo/python-list

--001a11c258f03bfc8b04f1579a13--