How to get the output from os.system() into a variable?

Björn Lindström bkhl at stp.lingfil.uu.se
Wed Oct 5 09:48:44 EDT 2005


"alexLIGO" <dietz at rouge.phys.lsu.edu> writes:

> I would like to execute some command in python on the bash, e.g.
>
> os.system('globus-job-run mike4.cct.lsu.edu/jobmanager-pbs -l
> /bin/date')
>
> and want the result of the output in a vector, so something like:
>
> result=python_command(' command_on_the_bash ')
>
> Is that possible? And how to do that?

Check out the commands module.

http://docs.python.org/lib/module-commands.html

-- 
Björn Lindström <bkhl at stp.lingfil.uu.se>
Student of computational linguistics, Uppsala University, Sweden



More information about the Python-list mailing list