[OSC_dev] No dumpOSC output in pipe in non-interactive terminal

Stephen Sinclair radarsat1 at gmail.com
Sat Sep 8 13:23:02 PDT 2007


Hi,

> > However, if you do want to call an external program and capture its
> > output, I suggest looking up the "popen" function.
>
> An equivalent to this is exactly what I tried to use in the first
> place, and where I ran into the problems reported in my first email
> here :-P

Looking at the dumpOSC.c source file, there is nothing special
happening for the output.  It simply uses printf to the standard
output.  There is even an fflush(stdout) in one place to ensure that
the output is printed immediately after the message is received.

I just tested the following code (Ubuntu Linux), and I was able to
send it messages from PureData.  It printed them out to the terminal
as expected.

Steve


#include <stdio.h>

int main()
{
    char buf[1024];
    int pos=0;
    char c;
    FILE* f = popen("./dumpOSC 8000", "r");
    if (!f) {
        printf("Couldn't execute dumpOSC.\n");
        return 1;
    }

    while (fgets(buf, 1024, f)) {
        printf("%s", buf);
    }

    return 0;
}


More information about the OSC_dev mailing list