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


Groups > comp.lang.python > #30953 > unrolled thread

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

Started byDennis Lee Bieber <wlfraed@ix.netcom.com>
First post2012-10-08 00:47 -0400
Last post2012-10-08 00:47 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2012-10-08 00:47 -0400
SubjectRe: how to run shell command like "<<EOT .... EOT"
Message-ID<mailman.1948.1349671651.27098.python-list@python.org>
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/

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web