Admins Please Sticky This Topic
alot of users will find it useful.
I knew there had to be an easy way to get sudo to report stdOut to pascal and after
a weeks time I finally came up with this simple solution

keep in mind yourpassword is your sudo password on your machine so
change it accordingly

However I did not get it done with shell, but I did discover a way to do away with
all the garbage on the hundreds of examples i tinkered with. As you guessed
it uses TProcess to pipe input through sh to return stdOut, or stdErr
Uses
Process
var
hprocess: TProcess;
hProcess := TProcess.Create(nil);
hProcess.CommandLine := 'sh -c "echo yourpassword | sudo -S fdisk -l"';
hProcess.Options := hProcess.Options + [poWaitOnExit, poUsePipes];
hProcess.Execute;
memo1.Lines.LoadFromStream(hprocess.Output);
hProcess.Free;
Best part is you can pipe as many arguments as you need
for example, you could install packages from respo using:
hprocess.CommandLine := 'sh -c "echo yourpassword | sudo -S apt-get -y install binutils"';
and report the output to your program in a memo control rather then it opening a terminal.
Being how commandline is depreciated im going to attempt to make it work with Executeable
if i succeed i will report back. even though commandline is depreciated it still works and compiles
fine at the time of this writing.
quick simple and does exactly what I needed it to

Keep It Simple Stupid