Avi Berkovich wrote:
Hey,

I can't make it work, I don't get any data from either stdout nor stderr.
If I send lines and then close the stdin pipe, I may get an exception message from several lines up.


I tried manually reading from the stdout pipe, but it just blocks and hangs no matter what I send over via the stdin pipe.

This behavior isn't presented by the command line interpreter by any chance.

Any suggestions?

Well,

I didn't manage to get the pipes working, and finally decided to embed the interpreter into the program, though another option is to embed it into a simple console program consisting of the interpreter initialization and input reading, and just pipe into that.

Code for simple interpreter embedded program:

#include <stdio.h>
#include <python.h>

int main()
{
        char execString[128];

        Py_Initialize();

        while (1)
        {
                gets(execString);
                if (!strcmp(execString, "QUIT PROGRAM"))
                        break;
                PyRun_SimpleString(execString);
        }

        Py_Finalize();
}


This program works well with pipes, though in order to issue the command I have to write "\n\r\n" (not "\r\n" or "\n" ?!) to the pipe.


Avi.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to