Reputation: 1493
How can I run a command line utility in Linux from a Delphi 10.2/10.3 application and capture the output for further processing?
I need the capturing to go line by line to watch the progress as I am going to use a GUI application with FMXLinux. This approach for OSX works perfectly
Delphi: Capture OSX console output
Thanks!
Upvotes: 0
Views: 960
Reputation: 1493
The example mentioned above created for OSX works perfectly on Linux64 (tested with current Ubuntu) with a small modification in the definitions. As the changes are small, I don't repeat the code (see Delphi: Capture OSX console output):
Add
Posix.Base
and
Posix.Fcntl
to uses clause
Change libc function declarations by exchanging the underscore by _PU:
... cdecl; external libc name _PU + 'popen'; ...
Now it compiles and works for OSX and Linux as well!
Upvotes: 2