<HTML><BODY><div>You are reading the output incorrectly, this should be done in a loop:</div><div> </div><div><a href="https://wiki.lazarus.freepascal.org/Executing_External_Programs#Reading_large_output">https://wiki.lazarus.freepascal.org/Executing_External_Programs#Reading_large_output</a></div><div> </div><div>To avoid doing this manually, use the "RunCommand":</div><div> </div><div><a href="https://wiki.lazarus.freepascal.org/Executing_External_Programs#(Process.)RunCommand">https://wiki.lazarus.freepascal.org/Executing_External_Programs#(Process.)RunCommand</a></div><div> </div><div>In general, study this article. There are a lot of details there, and options that you can choose, depending on what you need.</div><div> </div><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">Пятница, 24 января 2025, 19:18 +05:00 от Terry A. Haimann via fpc-pascal <fpc-pascal@lists.freepascal.org>:<br> <div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_17377283111663609465_BODY"><br>I recently tried to execute a sed command from Lazarus, but didn't receive any output. But when I imbedded the sed command in a script and then executed the script from tprocess, it worked fine. Why is this? I have run across similar issues from other Linux commands when trying to execute them from a Free Pascal program. The work around I have found is to hide them in a script. Not pretty, but it works.<br><br>This was run on a i7-8700 and I am running Linux Mint 20.2 and am using Mate 1.24<br><br>Source Code<br><br>Function CaptureArtWork(b, e: LongInt): TStringList;<br>Var<br> ArtProc: TProcess;<br> ArtSL: TStringList;<br> i: LongInt;<br>Begin<br> ArtProc := TProcess.Create(nil);<br> ArtSL := TStringList.Create;<br> ArtProc.Executable := 'sed';<br> ArtProc.Parameters.Add('-n');<br> ArtProc.Parameters.Add('"' + IntToStr(b) + ',' + IntToStr(e) + 'p"');<br> ArtProc.Parameters.Add('MyFileName');<br> ArtProc.Options := ArtProc.Options + [poWaitOnExit, poUsePipes];<br> ArtProc.Execute;<br> ArtSL.LoadFromStream(ArtProc.Output);<br> ArtProc.Free;<br> CaptureArtWork := ArtSL;<br>End;<br>--<br>Terry A. Haimann <<a href="/compose?To=terry@haimann.us">terry@haimann.us</a>><br>_______________________________________________<br>fpc-pascal maillist - <a href="/compose?To=fpc%2dpascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br><a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" target="_blank">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a></div></div></div></div></blockquote><div> </div></BODY></HTML>