[Baypiggies] how can I change the input parameter in my executable while calling from either os.system or os.popen calls?

David Elsen elsen.david08 at gmail.com
Thu Aug 21 18:30:18 CEST 2008


Shannon,
It is a very big reference for a very small question. I tried to glance and
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:

>  On Wed, Aug 20, 2008 at 5:53 PM, David Elsen <elsen.david08 at gmail.com>
> wrote:
> > Hello all,
> >
> > I have defined a class as following:
> >
> > class reg:
> >      def __init__ (self, offset):
> >                 self.offset = offset
> >
> >      def reg_read(self, offset):
> >              print 'Read the reg conten specified by offset'
> >              import os
> >              read_cmd = './testtool  0x50'
> >              read_content = os.popen(read_cmd).read()
> >
> > reg1 = reg (0x50)
> >
> > reg1.reg_read(0x50)
> >
> >
> > The above code calls my c executable with offset 0x50 and gives me the
> > content of 0x50 offset.
> >
> > I wanted to change the above code as following:
> >
> > class reg:
> >      def __init__ (self, offset):
> >                 self.offset = offset
> >
> >      def reg_read(self, offset):
> >              print 'Read the reg conten specified by offset'
> >              import os
> >              read_cmd = './testtool  offset'
> >              read_content = os.popen(read_cmd).read()
> >
> > reg1 = reg (0x50)
> >
> > reg1.reg_read(0x50)
> >
> > Basically I wanted to pass the offset as input parameter to my executable
> > "testtool" and run the testtool for offset.
> >
> > But looks like it does not allow me to change my offset.
> >
> > Is there a way to do this in python?
> >
> > Thanks in advance,
> > David
>
> 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.
>
> -jj
>
> --
> Don't you wish you had a really clever sig like mine?
> http://jjinux.blogspot.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20080821/cd2dc254/attachment.htm>


More information about the Baypiggies mailing list