[fpc-devel] Running programs with output redirection

Hans-Peter Diettrich DrDiettrich1 at aol.com
Sat Jul 16 22:37:19 CEST 2011


There seems to exist an issue with (output) redirection, when I try to 
run an external program from code. What I want to achieve is this:

In a Win32 console I can run
 >diff -r dir1 dir2 > diff.txt

When I use e.g. Exec('diff', args), diff complains about an excess 
argument, it works when "> diff.txt" is removed. With other functions I 
had less luck (ExecuteProcess, CreateProcess...), no output at all.

Now I assume that output redirection is a shell feature, not available 
in direct invocation of an external program. Right?

Does there exist a simple way to run "diff", and to redirect its output 
into an file? A batch file? Platform independence would be nice, of course.

DoDi




More information about the fpc-devel mailing list