Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30953

Re: how to run shell command like "<<EOT .... EOT"

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '"""': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:command': 0.09; '"""\\': 0.16; '(),': 0.16; 'oct': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'retains': 0.16; 'subject:run': 0.16; 'mon,': 0.16; 'string': 0.17; '>>>': 0.18; 'command': 0.24; '???': 0.27; 'skip:e 30': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; 'subject:like': 0.29; "skip:' 10": 0.30; 'code': 0.31; "skip:' 20": 0.32; 'print': 0.32; 'quotes': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'received:org': 0.36; 'but': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'subject:....': 0.65; 'as:': 0.75; 'dennis': 0.91; 'received:108': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: how to run shell command like "<<EOT .... EOT"
Date Mon, 08 Oct 2012 00:47:44 -0400
Organization > Bestiaria Support Staff <
References <506555B6.5040406@eisoo.com> <CAH8GtdMW0Eji1LtsafUzY1Av7OASzTxHW6c8KS+3MNg4YvErww@mail.gmail.com> <50664543.1050809@eisoo.com> <CAH8GtdO4LuVQU8tCdJqG4SzT2VxYvH0pWS4Mzrc4HmzB1obNZg@mail.gmail.com> <5072241A.8000201@eisoo.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-79-223-224.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1948.1349671651.27098.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1349671651 news.xs4all.nl 6926 [2001:888:2000:d::a6]:58449
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30953

Show key headers only | View raw


On Mon, 08 Oct 2012 08:53:46 +0800, ??? <ye.youqun@eisoo.com> declaimed
the following in gmane.comp.python.general:


> fop = os.popen ("sfdisk -uM %s <<EOT\n,%d,83\n,,83\nEOT\n" % (target, fps))
> 
> But when I run it with subprocess.Popen (), it doesn't work as os.popen 
> even use the code as:
> 
> command = ["sfdisk", "-uM",  target ]
> instructions = """

	Try with a \ at the end of the above line. The triple quoted string
retains ALL line endings, including the one from the quotes down to the
following line.

> ,1000,83
> ,,83
> """
>
 
>>> INSTRUCTIONS = """
... ,1000,83
... ,,83
... """
>>> 
>>> print repr(INSTRUCTIONS)
'\n,1000,83\n,,83\n'
>>> for c,ln in enumerate(INSTRUCTIONS.split("\n")):
... 	print c, '"%s"' % ln
... 	
0 ""
1 ",1000,83"
2 ",,83"
3 ""

vs

>>> INSTRUCTIONS = """\
... ,1000,83
... ,,83
... """
>>> print repr(INSTRUCTIONS)
',1000,83\n,,83\n'
>>> for c,ln in enumerate(INSTRUCTIONS.split("\n")):
... 	print c, '"%s"' % ln
... 
0 ",1000,83"
1 ",,83"
2 ""
>>> 
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: how to run shell command like "<<EOT .... EOT" Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-08 00:47 -0400

csiph-web