[Baypiggies] how can I change the input parameter in my executable while calling from either os.system or os.popen calls?
elsen.david08 at gmail.com
Thu Aug 21 20:59:11 CEST 2008
Yes, it works fine for me. Not sure if there is a better way to do this. I
am happy for now.
Ton of thanks to everyone for help. You guys are great.
On Thu, Aug 21, 2008 at 10:12 AM, Eric Walstad <eric at ericwalstad.com> wrote:
> On Thu, Aug 21, 2008 at 9:30 AM, David Elsen <elsen.david08 at gmail.com>
> > Shannon,
> > It is a very big reference for a very small question. I tried to glance
> > could not get my solution.
> > Thanks a lot for the reference though,
> > David
> > On Wed, Aug 20, 2008 at 5:59 PM, Shannon -jj Behrens <jjinux at gmail.com>
> > wrote:
> >> Have a peek at http://docs.python.org/lib/module-subprocess.html.
> >> This has the additional benefit that you can pass a list of args
> >> instead of a single string.
> def reg_read(self, offset):
> import subprocess
> read_cmd = './testtool'
> args = (read_cmd, offset)
> process = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE)
> return_code = process.wait()
> read_content = process.stdout.read()
> This stuffs the read_cmd and the offset into a tuple which is then
> used as the first argument to create a Popen object. Doing it this
> way means that you don't have to worry about formatting the read_cmd
> into something that includes the arguments passed into the testtool
> executable - Popen handles that for you.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Baypiggies