hep needed with pipes (popen4)

Darcy Kahle dkahle at interactdirect.com
Fri Feb 22 16:38:40 EST 2002


I need some help with pipes in python 2.1.

I am running a comand using os.popen4().  The command produces output until
the user hits control-C, at which time, it prints a summary, and exits.  I
want to send that character down the pipe to it without the user doing so
(control-c kills the script, by default).  I tried sending "\x003", which to
the best of my knowledge, is the hex code for it, but it didn't work.

If this is not possible, then I could do the same by redirecting the stdin
to /dev/null, but if I do that at the start, the command will stop
immediately.

Does anyone know the correct character sequence to send control-C to the
command or how to redirect the command's stdin to /dev/null after it is run?

I was toying with os.dup2(), but I suspect that that will redirect the file
handle inside my program to /dev/null, leaving the stdin of the command
intact.  I was hoping that it would link the two file handles together,
thereby creating a bridge between the two.

Any assistance that you can provide, will be greatly appreciated.

Darcy





More information about the Python-list mailing list