TProcess Output dans terminal impossible ?
Bonjour,
Le code ci-dessous:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| procedure TForm1.BitBtn1Click(Sender: TObject);
var
AProcess : TProcess;
Tfile: TextFile;
StrResult: String;
begin
AProcess := TProcess.Create(nil);
AProcess.Executable:='ps';
AProcess.Executable := 'ps';
AProcess.Parameters.Add('-U');
AProcess.Parameters.Add('moi');
AProcess.Options := [poUsePipes];
// Start the process (run the dir/ls command)
AProcess.Execute;
AssignStream(TFile,AProcess.Output);
Reset(TFile);
while not EOF(TFile) do begin
ReadLn(TFile,StrResult); // read a single line
Memo1.Lines.Add(StrResult);
end;
AProcess.Free;
end; |
Fonctionne parfaitement avec des commandes Linux mais ce que je n'arrive pas à faire c'est utiliser gnome-terminal comme process et récupérer tout ce qui s'y affiche quand un programme est lancé depuis le terminal. Ça pourrait venir du fait qu'une fois appelé gnome-terminal tourne en tant que /usr/lib/gnome-terminal/gnome-terminal-server/ mais avec xterm qui ne change pas de process à l'exécution c'est tout autant impossible.
Existe t-il un moyen de récupérer les lignes d'un terminal dans un memo ou une stringlist ?