[OSC_dev] No dumpOSC output in pipe in non-interactive terminal
Torsten Anders
torsten.anders at plymouth.ac.uk
Sat Sep 8 19:24:50 PDT 2007
Dear Stephen,
thanks a lot for your effort on this! Unfortunately, this wrapper
behaves as the original: it works fine in the terminal, but prints
nothing when run from within my language. I really don't understand
it :-P
BTW: in dumpOSC.c, only after printing each message is flush()
called, but not after printing bundles. So, in a pipe, bundles are
only finished after the next message arrives -- which was easy to fix
with an additional fflush(stdout) after the printf("]\n") in line 348...
Best
Torsten
On Sep 8, 2007, at 5:23 PM, Stephen Sinclair wrote:
> 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;
> }
> _______________________________________________
> OSC_dev mailing list
> OSC_dev at create.ucsb.edu
> http://www.create.ucsb.edu/mailman/listinfo/osc_dev
--
Torsten Anders
Interdisciplinary Centre for Computer Music Research
University of Plymouth
http://strasheela.sourceforge.net
http://www.torsten-anders.de
More information about the OSC_dev
mailing list