Using os.popen with other python scripts

William Park parkw at better.net
Tue May 4 14:24:07 EDT 1999


On Tue, May 04, 1999 at 04:32:55PM +0000, skott1870 at my-dejanews.com wrote:
> 
> 
> I'm having trouble using os.popen within a script to capture the output of
> another script.
> For example:
> 
> Script 1:
> 
> print "this is a test"
> 
> Script 2:
> 
> import os
> x = os.popen('script1.py').readlines()
> print x
> 
> Script2's output is just an empty list. I'm working on an NT system, through a
> dos window.
> Does anyone know what could be causing this behavior?
> 
> Thanks,
> TST
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list

I'm not familiar with NT system.  But, don't have to specify "python"
interpretor somewhere when you invoke script1?  Perhaps, script1.py is
missing
    #!/usr/local/bin/python
or script2.py needs 
    os.popen('python script1.py').readlines()

William




More information about the Python-list mailing list