is their any limit on the size of the data passed to a progra m via popen2?

husam h.jehadalwan at student.kun.nl
Sat Feb 23 04:33:08 EST 2002


Carel Fellinger wrote:

> husam <h.jehadalwan at student.kun.nl> wrote:
> 
> 
>>hi Gustaveo,
>>You'r solution did not work either. The code hangs at the first loop, 
>>specifically at "log.write(o.read())".
>>
> 
> You don't seem to be having a Python problem, so what about trying to
> get some output from the program?  Instead of reading the log into a



> var, what about trying it with `os.popen("/home/programs/profit", "w)'

Off course, it works this way. But, then I have to execute another 
script to process the output. Therefor I chosen for "popen2" so that I 
can process the output in the same script.



> and have the output directed at the terminal for direct inspection.
> Maybe you're just missing error messages:)
> 
> An other problem that might buck you (but I don't see how this would
> be the case as your program seems to work for a few files) is that
> pipes are buffered.  So uses `i.flush()' to be sure that what you


I'v tried "flush()" already, no go.


> wrote really is transmitted to the other end of the pipe.
> 
> And as a last resort you could try reading the `ls' output a line at a
> time.
> 
>     i = os.popen("/home/programs/profit ", "w")
> 
> Should this ---------------------------^ space be there?


The space is needed here, otherwise the command and it's arguments 
passed to the progam, get passed like this: "CommandArguments" instead 
of " Command Arguments"


> 
>     i.write("reference /usr/local/3D_Dock/progs/Complex_1g.pdb ") 
>     for PDB in os.popen('ls /home/data/pdbs'):
>         i.write(" mobile /home/data/pdbs/" + PDB + "\n")
> 
> Should this -----^ space be there?


The same explanation as above!

> 
>         i.write("fit\n")
>         i.flush()
>     i.close()
> 





More information about the Python-list mailing list