system exec ?
aleaxit at yahoo.com
Thu Jul 5 12:27:59 CEST 2001
"alphaZeta" <NOSPAM.hnguyen421 at NOSPAM.hotmail.com> wrote in message
news:9i1er4$mth$1 at news.businessobjects.com...
> I didn't find any documentation (lib and tut) about how to execute a
> 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).
More information about the Python-list