0

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!

1
  • Thanks for voting down without explanation. Commented Dec 10, 2018 at 20:47

1 Answer 1

2

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):

  1. Add

    Posix.Base

    and

    Posix.Fcntl

    to uses clause

  2. Remove line with path to libc.dylib
  3. 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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.