[fpc-devel] Running programs with output redirection

Mark Morgan Lloyd markMLl.fpc-devel at telemetry.co.uk
Sun Jul 17 11:51:12 CEST 2011


Ludo Brands wrote:
>> This is all windows though.
>>
> 
> Cross platform solution:
> 
> Uses process
> 
> ...
>   p:=TProcess.Create(nil);
> {$IFDEF WIN32}
>   p.CommandLine := 'cmd /c diff -r dir1 dir2 > diff.txt';
> {$ENDIF}
> {$IFDEF LINUX}
>   p.CommandLine := 'bash -c "diff -r dir1 dir2 > diff.txt"';
> {$ENDIF}
>   p.Execute;

Might be safer to refer to sh rather than bash in this context, since 
Debian and Ubuntu are moving from Bash to Dash with sh being an 
appropriate symlink.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-devel mailing list