I've downloaded processutils.pas and added it to my project.
Here is my new code:
unit getpartitioninfo;
{$mode objfpc}{$H+}
interface
uses
Classes, Controls, Dialogs, FileUtil, Forms, Graphics, Processutils, StdCtrls, SysUtils;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
hprocess: TProcessEX;
sPass: String;
OutputLines: TStringList;
begin
sPass := Edit1.text;
OutputLines:=TStringList.Create;
hProcess := TProcessEx.Create(nil);
hProcess.Executable := '/bin/sh';
hprocess.Parameters.Add('-c');
hprocess.Parameters.add('echo ' + sPass + ' | sudo -S fdisk -l');
hProcess.Options := hProcess.Options + [poWaitOnExit, poUsePipes];
hProcess.Execute;
Memo1.Lines.add('stdout:');
Memo1.Lines.LoadFromStream(hprocess.Output);
Memo1.Lines.add('stderr:');
Memo1.Lines.LoadFromStream(hprocess.Stderr);
Memo1.Lines.add(OutputLines.Text);
Memo1.Lines.Add('Program completed');
hProcess.Free;
OutputLines.Free;
end;
End.
When I compile I get:
Compile Project, Target: Command_1: Exit code 256, Errors: 2
getpartitioninfo.pas(50,43) Error: Identifier not found "poWaitOnExit"
getpartitioninfo.pas(50,57) Error: Identifier not found "poUsePipes"
What do I have to do correct these?