[fpc-pascal] Why does RunCommand not produce the correct output?

tsiegel at softcon.com tsiegel at softcon.com
Tue May 2 01:15:38 CEST 2023

Well, you could use the infile and outfile redirect functionality.  I 
don't know how it's done in fpc, but the manual should get you the 
proper syntax.  Simply redirect the text output to a file or buffer, 
then redirect the input file buffer as well, and feed the output from 
the first command to the input of the next one.  I've seen it done, but 
it was quite some time ago, and I don't remember the specifics.  With 
this method, it would take multiple steps, but you could then control 
the process from start to finish.  The only issue is you'll have to put 
in the full path of the commands you're running, since there won't be 
any shell running to use the path for locating the programs you want.

In all likelihood, the programs you're using will be in /usr/bin, but 
unfortunately, there's no guarantee of that.

On 5/1/2023 5:38 PM, Bo Berglund via fpc-pascal wrote:
> On Mon, 1 May 2023 14:25:28 -0400, Travis Siegel via fpc-pascal
> <fpc-pascal at lists.freepascal.org> wrote:
>> You could just add the line:
>> #!/bin/bash
>> to the first line of your script, then just call the script from your
>> program.
>> Alternatively, you could call the bash command, and pass the command to
>> it that way, either one should get you the output you desire.
> I did already create a script "listserial" that does the extraction:
> (long line split by newsreader)
> -----------------------------
> #!/bin/bash
> SERLIST=$(ls -l /sys/class/tty/*/device/driver | grep -v
> "platform/drivers/serial8250" | awk '{print $9}' | awk -F'/' '{print "/dev/"
> $5}')
> echo $SERLIST
> -----------------------------
> This successfully lists the available serial ports by their device name, which
> can be used to open the port using the built-in serial unit functionality.
> Of course I *could* call the script from the program but I wanted it all be
> within the FPC program itself...
> But it can be done by calling the standalone script file of course...

More information about the fpc-pascal mailing list