Problem with pipes (win32pipe)
Jeremy Gibson
augspies at charter.net
Mon Dec 3 15:03:59 EST 2001
I am having a bear of a time trying to get my python program to talk to a
windows process. The program I am trying to run is call nrcmd. It is a
cisco program that is used for administering router clusters.
Here is what I have done so far(BTW) the kludgey readlines are going to
be replaced with some pattern matching I just wanted to get talking first.
*****************************************************
import os, win32pipe
os.chdir('c:\\program files\\network registrar\\bin')
fin, fout = win32pipe.popen2('nrcmd')
c = 0
while c < 6:
fout.readline()
c = c+1
fout.read(7)
*****************************************************
The output from this is:
*****************************************************
100 Ok\n
cluster = nnn.nnn.nnn.nnn\n
default-format = user\n
user-name = user \n
visibility = 5\n
nrcmd>
*****************************************************
At this point any fin.write() will be accepted without complaint, but
nothing is happening. If I attpempt to fout.read() again the program
hangs and must be killed. I assume this is happening because I am
attempting to read a null byte. The return from a successfull (or
unsuccessfull) write should fill the fout buffer with something to read.
I am sending newlines in the fin.writes I've tried and I've even tried
sending \r\n since this is a windows machine I'm working with. I've also
tried fin.flush() after a write.
If anyone has any ideas or thoughts on where I might find illumination
for this problem please write to my email, or post to the group.
Thanks,
Jeremy Gibson
More information about the Python-list
mailing list