Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: how to run shell command like "<<EOT .... EOT"

Reply
Thread Tools

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

 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      10-08-2012
On Mon, 08 Oct 2012 08:53:46 +0800, ??? <(E-Mail Removed)> 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
http://www.velocityreviews.com/forums/(E-Mail Removed) HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: how to run shell command like "<<EOT .... EOT" Kushal Kumaran Python 0 09-29-2012 11:53 AM
how to run os.execv() to run command pslq dbname < gen.command Sonu Python 2 08-04-2007 11:25 PM
Run Unix shell command $ parse command line arguments in python rkoida@yahoo.com Python 4 04-23-2005 04:42 AM
can I run unix shell command in the ModelSim shell? clinton__bill@hotmail.com VHDL 2 02-18-2005 10:04 PM



Advertisments