Forum > Linux
Result from shell command
(1/1)
dryzone:
program example56;
uses Unix;
With the manual example below I can obtain the exit status of a shell command.
Is it possible to read the result of the shell command into a string to be used in an fpk program ?
{ Program to demonstrate the Shell function }
Var S : Longint;
begin
Writeln ('Output of ls -l *.pp');
S:=fpSystem('ls -l *.pp');
Writeln ('Command exited with status : ',S);
end.
MarkMLl:
Please put your program examples into code tags, otherwise they'll be mangled.
You can do what you want using TProcess, see the documentation and wiki.
MarkMLl
TRon:
Alternatively and in addition to the already provided answer and in case only interested in the resulting output RunCommandInDir is an option. As indicated in the wiki as Executing External Programs to which was linked in a previous discussion about the same topic.
Using TProcess however provides more control over the whole process of executing an external program.
dryzone:
Tron.
Thank you for the pointers, I will look into that. I looked in the manual but couldn't find anything.
Navigation
[0] Message Index