Is it possibe to pipe the console output of a GUI application into this application itself?
I am posting in the Linux Part of the forum->
os is Linux, or better Raspbian.
I run a GUI application, when calls receive a -1 as return, error messages of the called underlying os processes are posted on the console.
I can see that the Lazarus debugging session in the console window of the debugger.
I want to be able to show those messages in my application.
Without debugger.
My solution will only trap Pascal output.
If he means gtk errors etc, I don't know.
My solution will only trap Pascal output.
If he means gtk errors etc, I don't know.
Maybe to make it more clear, if I start the application in a console "./libsockuse" or "sudo ./libsockuse" (this is at least required if I want to use it with root rights to set CAN configuration), it will show the (error) messages in that shell window. This is what I want to catch and show it in the application itself.
Right, so you're running from a shell: standard TProcess stuff IIRC. There's other possibilities e.g. using a pty, if you're stuck I'll look for examples later.
I want the outputs of processes which show up in the console if I would start from the console.Take a look at RunProcess() at https://bitbucket.org/avra/ct2laz/src/master/utils.pas. It runs external process and captures it's output to a memo on both linux and windows.
As a slight aside: Marco, am I correct in that the Lazarus IDE doesn't have an interactive shell-out facility?
My solution will only trap Pascal output.
If he means gtk errors etc, I don't know.
Maybe to make it more clear, if I start the application in a console "./libsockuse" or "sudo ./libsockuse" (this is at least required if I want to use it with root rights to set CAN configuration), it will show the (error) messages in that shell window. This is what I want to catch and show it in the application itself.
Test Before
read: Test After
As a slight aside: Marco, am I correct in that the Lazarus IDE doesn't have an interactive shell-out facility?
Afaik indeed it doesn't. It was designed for systems that could run more tasks in parallel, so there was no need for functionality to suspend the IDE to run a shell like old DOS IDEs did.
Yes, I agree with Fred. I found a SO post (https://stackoverflow.com/questions/955962/how-to-buffer-stdout-in-memory-and-write-it-from-a-dedicated-thread) that solved this problem using Dup2 and pipes. This way you don't need a "file". I tested the idea on an Android terminal. Seemed to work: