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

2023-05-02 Thread Bo Berglund via fpc-pascal
On Mon, 01 May 2023 11:00:56 -0400, Bo Berglund via fpc-pascal wrote: >I am trying to create a function to list the available serial ports on a Linux >device. But I have trouble getting commands which work on a terminal to also >work when run from my console program. > >When I run this conmmand

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

2023-05-01 Thread Travis Siegel via fpc-pascal
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

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

2023-05-01 Thread Bo Berglund via fpc-pascal
On Mon, 1 May 2023 14:25:28 -0400, Travis Siegel via fpc-pascal 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

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

2023-05-01 Thread Travis Siegel via fpc-pascal
As mentioned in another post, you'll need to run a shell, (whether it be bash or another system provided shell), in order to process the commands.  If you run the commands directly, there is no shell interpretation, and the | which passes the output of one command to the input of the next one

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

2023-05-01 Thread Jean SUZINEAU via fpc-pascal
Le 01/05/2023 à 17:00, Bo Berglund via fpc-pascal a écrit : I have created a shellscript with the same command string May be running directly your script in bash: RunCommand('/bin/bash', ['your_script.sh' ], OutData) ___ fpc-pascal maillist -

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

2023-05-01 Thread Jean SUZINEAU via fpc-pascal
I don't have an example at hand but I think you should run a bash interpreter, something like : RunCommand('/bin/bash', ['-c', ListCmd], OutData) but I'm not 100% sure. There is a good documentation at: https://wiki.freepascal.org/Executing_External_Programs May be you need to split your