<div dir="ltr"><div>Yes, it works fine for me. Not sure if there is a better way to do this. I am happy for now.</div>
<div> </div>
<div>Ton of thanks to everyone for help. You guys are great.</div>
<div> </div>
<div>David<br><br></div>
<div class="gmail_quote">On Thu, Aug 21, 2008 at 10:12 AM, Eric Walstad <span dir="ltr"><<a href="mailto:eric@ericwalstad.com">eric@ericwalstad.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="Ih2E3d">On Thu, Aug 21, 2008 at 9:30 AM, David Elsen <<a href="mailto:elsen.david08@gmail.com">elsen.david08@gmail.com</a>> wrote:<br>> Shannon,<br>> It is a very big reference for a very small question. I tried to glance and<br>
> could not get my solution.<br>><br>> Thanks a lot for the reference though,<br>> David<br>><br>> On Wed, Aug 20, 2008 at 5:59 PM, Shannon -jj Behrens <<a href="mailto:jjinux@gmail.com">jjinux@gmail.com</a>><br>
> wrote:<br></div>
<div class="Ih2E3d">>> Have a peek at <a href="http://docs.python.org/lib/module-subprocess.html" target="_blank">http://docs.python.org/lib/module-subprocess.html</a>.<br>>> This has the additional benefit that you can pass a list of args<br>
>> instead of a single string.<br><br></div>Consider:<br>
<div class="Ih2E3d">def reg_read(self, offset):<br></div> import subprocess<br> read_cmd = './testtool'<br> args = (read_cmd, offset)<br> process = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)<br>
return_code = process.wait()<br> read_content = process.stdout.read()<br><br>This stuffs the read_cmd and the offset into a tuple which is then<br>used as the first argument to create a Popen object. Doing it this<br>
way means that you don't have to worry about formatting the read_cmd<br>into something that includes the arguments passed into the testtool<br>executable - Popen handles that for you.<br></blockquote></div><br></div>