I am trying to use TProcess to get some information about what is happening on my Raspberry pi. Some of it is working fine. the following code is OK
Var
AProcess : TProcess;
AStringList : TStringList;
ResultStr : String;
Begin
AStringList := TStringList.Create;
AProcess := TProcess.Create(nil);
ResultStr := '';
Try
AProcess.Executable := 'vcgencmd';
Aprocess.Parameters.Add('measure_temp');
AProcess.Options := [poWaitOnExit, poUsePipes];
AProcess.Execute;
AStringList.LoadFromStream(AProcess.Output);
ResultStr := AStringList.Text;
finally
AStringList.Free;
AProcess.Free;
end;
and I get the information I expected in ResultStr. However if I try the following
AStringList := TStringList.Create;
AProcess := TProcess.Create(nil);
ResultStr := '';
Try
AProcess.Executable := '/usr/bin/top';
Aprocess.Parameters.Add('-n 1 -p0');
AProcess.Options := [poWaitOnExit, poUsePipes];
AProcess.Execute;
AStringList.LoadFromStream(AProcess.Output);
ResultStr := AStringList.Text;
finally
AStringList.Free;
AProcess.Free;
end;
ResultStr is always empty. I assume it might be something to do with top clearing the screen before it starts but I am not sure how to get round this and wondered if anyone had any ideas.
Many thanks
Regards
Barry