Trying to use cscope via pipes

P

Paul Walker

Hi all,

I'm currently trying to put together a small script to talk to cscope
(http://cscope.sf.net/) via pipes. The obvious way to do this is via
popen2 (or popen4).

I've tried both the one in the os module and the one in the popen2
module, and I get the same effect with both - I don't get any response
on the stdout pipe until I've closed the stdin pipe, even if I call
flush().

What I'm trying to do should be possible, I think - cscope says that
it supports a line-oriented interface for this kind of thing, and the
cbrowser tool (written in tcl) uses cscope as a backend via pipes. So
the conclusion is that I'm missing something, but I can't quite work
out what... any ideas?

Script:

==
from os import popen2

handles = popen2("cscope -d -l")
writer = handles[0]
reader = handles[1]

writer.writelines("2bigphysarea_alloc_pages\n")
writer.flush()
#without closing it'll just hang... strange.
#writer.close()
lines = reader.readlines()
print lines
==

I'm using the following Python, since there aren't Python 2.3 RPMs
until Fedora C2 (and this is a work machine which I shouldn't update
too much):

Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2

Thanks,

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top