Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30953 > unrolled thread
| Started by | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| First post | 2012-10-08 00:47 -0400 |
| Last post | 2012-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.
Re: how to run shell command like "<<EOT .... EOT" Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-08 00:47 -0400
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2012-10-08 00:47 -0400 |
| Subject | Re: 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/
Back to top | Article view | comp.lang.python
csiph-web