[fpc-pascal]Exit codes of called programs.

A.J. Venter ajventer at direqlearn.org
Tue Apr 15 10:50:52 CEST 2003


Hi,
I often write frontends for commandline programs. 
When I need their output, I call assignstream, when I don't I use shell.

What I would like however, is a way to check the exit codes of such
programs, so that I can for example tell if a program failed to run
correctly. Not all programs have output, and you cannot always get the
output via assignstream, not to mention that you need to do a lot of
string parsing to make sense of it when you do. This is not always easy,
as you cannot always recognize every possible error message.

A system that can check wether the exit status was zero, and report and
error if it wasn't would be much more ellegant
How could I ran another program from within my own, while detecting the
exit code ?
I foresea something like this.

If runWithExitStatus('ls -alh') <> 0 then
Begin
	Writeln ('Error reading files');
	halt(1);
end;
-- 
Story of my life: "Semper in excretum, set alta variant"
A.J. Venter
DireqLearn Linux Guru




More information about the fpc-pascal mailing list