how to pipe to variable of a "here document"

Burton Samograd kruhftREMOVE at gmail.com
Mon Apr 10 01:44:38 EDT 2006


eight02645999 at yahoo.com writes:

> I need to execute sql command using a "here document" like in unix.
> 
> os.popen("osql", "w").write("""\
> select * from table
> go
> """)
> 
> how can i pipe these result of the select into a variable?

popen doesn't work that way.  you can only open them read or write.
you'll have to create a couple of pipes (one for reading, one for
writing), do a fork, execve, etc with the posix api.  at least that's
how one does it in C...i'm a bit new to python so there might be
better ways.

-- 
burton samograd					kruhft .at. gmail
kruhft.blogspot.com	www.myspace.com/kruhft	metashell.blogspot.com



More information about the Python-list mailing list