Forum > Windows

Having trouble with TProcess and RunCommand on Windows

(1/2) > >>

rail5:
I should say I haven't used Windows for something like ten years, so I'm a bit lost trying to solve this one on my own

The problem I'm having is something like this:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---RunCommand('liesel', Options, ReturnString)
(where "liesel" is a cross-platform binary on both Windows & Linux, and "Options" is a TStringArray containing elements like '-i', 'some-input-path', '-g', '-v', '-o', 'some-output-path')

Runs just fine on Linux hosts, but fails on Windows with no error message & no execution

Conversely,


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---RunCommand('liesel', ['-h'], ReturnString)
Runs just fine on both systems


Likewise,


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Process1 := TProcess.Create(nil);Process1.Executable := 'liesel'; for i := 0 to (Length(Options)-1) dobegin  Process1.Parameters.Add(Options[i]);end; Process1.Options := [poUsePipes];Process1.Execute;
Runs just fine on Linux, but doesn't run at all on Windows


Is there something (as I'm hoping there is) incredibly obvious that I'm missing?

Thanks

trev:
Check what you have against the declaration:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function RunCommand(  const exename: TProcessString;  const commands: array of TProcessString;  out outputstring: string;  Options: TProcessOptions = [];  SWOptions: TShowWindowOptions = swoNone):Boolean;
It might also be worth adding error checking on the boolean return status which is currently ignored.

rail5:

--- Quote from: trev on December 24, 2021, 06:03:29 am ---Check what you have against the declaration:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function RunCommand(  const exename: TProcessString;  const commands: array of TProcessString;  out outputstring: string;  Options: TProcessOptions = [];  SWOptions: TShowWindowOptions = swoNone):Boolean;
It might also be worth adding error checking on the boolean return status which is currently ignored.

--- End quote ---

Hey thanks for the reply

Well after reading your post, setting the project target OS to Win32/Win64 and then clicking "Find declaration of RunCommand / Find declaration of Process" results in: "Error: unit not found: Process"

It still compiles without complaining, and I'm even more flummoxed now as to why RunCommand half-works on Windows builds if it isn't including the Process unit

Tried recompiling the cross-compiler ( as per https://wiki.lazarus.freepascal.org/Cross_compiling_for_Windows_under_Linux ), but same result

trev:
You need to add Process to your Uses clause.

rail5:
Sorry, I wasn't clear. It's already in the Uses clause (see the screenshot)

The "unit not found" error comes up when I switch the target OS to Win32 or Win64 (and yet, the project still builds)

The reason I tried re-compiling the cross-compiler was that I assumed there was a Win64 "version" of the Process unit that was somehow skipped the first time. Re-compiling didn't fix it though so I'm in the dark

Edit: Also, the compiler logs (from building the cross-compiler) say that the installation of 'fcl-process' was successful

Further edit: /etc/fpc.cfg also contains the line:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ----Fu/usr/lib/fpc/$fpcversion/units/$FPCTARGET/*
And the "fcl-process" directory (complete with process.o, process.ppu etc) is present in both /usr/lib/fpc/3.2.0/units/x86_64-win64/ and /usr/lib/fpc/3.2.0/units/i386-win32

Navigation

[0] Message Index

[#] Next page

Go to full version