system exec ?

alphaZeta NOSPAM.hnguyen421 at NOSPAM.hotmail.com
Thu Jul 5 08:07:53 EDT 2001


Thanks, I was also planning to use the readlines() method.


"Alex Martelli" <aleaxit at yahoo.com> wrote in message
news:9i1ffe029cm at enews1.newsguy.com...
> "alphaZeta" <NOSPAM.hnguyen421 at NOSPAM.hotmail.com> wrote in message
> news:9i1er4$mth$1 at news.businessobjects.com...
> > Hi,
> >
> > I didn't find any documentation (lib and tut) about how to execute a
> program
> > in a python script.
>
> os.system('theprogram') just executes it.  What you desire is different:
>
> > Does anybody know ?
> >
> > For example : I would like to store in a variable the result of a call
to
> > the system.
> > alike : >>> a = sys.exe("ls -l")
>
> a = os.popen("ls -l").read()
>
> may be what you want (but you may also prefer to call .readlines()
> instead for example, getting the result as a list of strings, one
> per line, rather than as one big string).
>
>
> Alex
>
>
>





More information about the Python-list mailing list