Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #30953
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Subject | Re: how to run shell command like "<<EOT .... EOT" |
| Date | 2012-10-08 00:47 -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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1948.1349671651.27098.python-list@python.org> (permalink) |
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
Re: how to run shell command like "<<EOT .... EOT" Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-10-08 00:47 -0400
csiph-web