Read from stdout in LCB?

Moderators: LCMark, LCfraser

Post Reply
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1764
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Read from stdout in LCB?

Post by [-hh] » Mon Nov 14, 2016 9:32 pm

Peter wrote in his blog ( ) how to implement System(pCommand). This works fine here and is especially usable in handlers where most LCS-workarounds don't work, e.g. in OnPaint().

If now pCommand writes data to stdout (and I do not want to use a file in between): Is there already a way to read data from stdout in LCB?
shiftLock happens

Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

Re: Read from stdout in LCB?

Post by peter-b » Mon Nov 14, 2016 10:18 pm

We'd need some more low-level subprocess management tools to be able to capture the output from a subprocess. The main blocker here is, unfortunately, the inability to do pointer arithmetic in LCB. Specifically, it's not currently possible to construct an argv array suitable for passing to posix_spawn(3). You may have noted me poking at my laptop for more of the conference. That was when I was trying very hard -- and failing -- to get that working!

Don't forget that the system(3) function uses the system shell to run the string that you pass to it. This means that you can put an output redirection to a temporary file, then read it in. I use this in the "vulcanbot" continuous integration automaton. However, note that it's a security hazard to use temporary files in this way. The reason I can get away with it in "vulcanbot" is that I run it as a systemd service with a private temporary directory that nothing else on the system can see (let alone mess with).

Getting enough C FFI stuff working for me to be able to write some simple subprocess helper tools is literally my top priority once we get to the C FFI part of the Infinite LiveCode project!
LiveCode Open Source Team — @PeterTBBrett —

Post Reply

Return to “LiveCode Builder”