Using os.popen with other python scripts

skott1870 at my-dejanews.com skott1870 at my-dejanews.com
Wed May 5 08:30:59 EDT 1999


In article <8DBD65246duncanrcpcouk at news.rmplc.co.uk>,
  Duncan Booth <duncan at rcp.co.uk> wrote

> I think the problem here is the same bug that hits you under NT when you
> try to redirect a python script from the command line. So while the command
> 'script1.py' (or 'script1' if you have set PATHEXT correctly) will print
> "this is a test", running 'script1.py >afile' will not write any output in
> the file, you have to use 'python script1.py >afile'.
>
> So although the os.popen is running the script, you will lose all output.
>
> The solution is to include 'python ' in the command as in:
> import os
> x = os.popen('d:\progra~1\python\python script1.py').readlines()
> print x

That is indeed what the problem was, thank you very much.
TST

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




More information about the Python-list mailing list