[fpc-pascal] TProcess questions

Michael Van Canneyt michael at freepascal.org
Tue Oct 3 09:26:21 CEST 2006

On Tue, 3 Oct 2006, Adrian Maier wrote:

> Hello,
> I have several questions about executing external programs with TProcess
> 1.  I need to execute the following command :
>  psql -q -f /home/am/src/gfaf/hlemit_d.sql  -v D1="'1-apr-06'" -v
> D2="'1-jun-06'"
> (it might not be obvious at first sight that there are both "  and  '
> enclosing those dates , because the argument must contain the '  ) .
> This command works fine when executed from the bash shell.  However, it
> no longer works when executed from my pascal program (with TProcess).
> Any idea how should i quote the arguments so that they would be properly
> treated by TProcess?

You can't. The following lines (line 107 of unix/process.inc)
Will strip all quotes inside a quoted string.

Obviously, this is a bug.

> 2.  Where is the TProcess documented on the freepascal website? I had
> found a FCL.pdf  some time ago , but I am unable to find that doc on the
> freepascal website.

It is not documented currently. It's scheduled as the next unit to be

> 3.  The code returned by the called program can be got with
> TProcess.ExitCode , right ?   I have a situation in which a program  1
> , but  TProcess.ExitCode is 0.   Therefore it's impossible to detect
> the failure.

That can be if the program exited because of a signal.


More information about the fpc-pascal mailing list