How to get stdout from OSX process

Hi
Assuming a process is running in OSX, and it is printing to stdout. I want to create a GUI to display the data. How do I get that data?
I have seen some mention that IPCsocket will do it. Also I wonder if a TextInputStream would work.

I’ve used IPCsocket, which uses a file. Could the answer be to redirect stdout of the process to that file, then read same with IPCsocket?

Thx
Tom

Use shell class and you get events for new data.

Thanks Christian.
So using Shell, I assume I need to launch the process from the Xojo desktop app…correct?

I think that should work for what I want to do. But to be thorough…what if the process is already running? One could use Shell to run ps, parse the result, and get a process ID. But from there…?

If you have control over how the process was started initially, you could start it using screen and attach to that later.

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/screen.1.html

Kem

That sounds interesting. I use ‘screen’ all the time for serial I/O. Can you give me an idea how one would launch using screen? That is a big man page. I don’t like reading that much :slight_smile:

I have been trying to run some embedded MCU C code on my Mac, as a process. I rewrote the hardware abstraction layer to do the I/O using stdin and stdout. The I/O has been encoded to indicate whether the text represent I/O bit state, analog voltage, user serial communication or whatever. That project stalled when I couldn’t figure out how to get a single character typed from the console (it is easy on Linux but not Mac). Which brings me back to ‘screen’. I presume it would be possible to create a virtual comm port that would show up in /dev. I don’t know how to do this in C, and that is off-topic anyway. But I wonder if that is possible in a Xojo console app? Is there a way that a Xojo console app can create a virtual serial port in /dev?

Yes. You will get the StOut from your process in Result.

A possible alternative is to launch your process and reroute its StdOut to a file with > so you read it from any other program.

./myProcess > myStdOutLog.Txt