First to your problem, try '/bin/bash -c "echo ... | sudo ..."
But, do you really want to execute your whole program as root? this get's really messy, if all you need is a single stream you could use something like this:
AProcess.CommandLine := 'sudo tail -f ' + Filename;
AProcess.Options := AProcess.Options + [poUsePipes];
AProcess.Execute;
// sudo asks for a passwort, so let's supply it with one
AProcess.Input.Write(Password[1], Length(Password));
AProcess.Input.WriteByte(#10); // Newline
AProcess.CloseInput; // tail does not require stdin, if the passwort is wrong, sudo will now terminate with an error code
// TODO: sudo error checking
// From this point onwards use AProcess.Output provides a stream to read from that file
This technique can also be used to read real files not only pseudo files that require root (by using cat instead of tail -f)
If you need a real filedescriptor in the filesystem, then you can use named pipes (fifos), by executing the following:
fpMkFifo('temporary.fifo', &600); // from unit BaseUnix
AProcess.CommandLine := 'bash -c "sudo tail -f ' + Filename + ' > temporary.fifo"'
...
Now you can read from temporary.fifo as if it is the real file, but with the difference that you own the file and tail does the reading as admin.
You of course need to delete the fifo afterwards, using fpUnlink from BaseUnix (probably DeleteFile also works)
This can also all be combined into one command:
AProcess.CommandLine := 'bash -c "mkfifo temporary.fifo && sudo tail -f ' + Filename + ' > temporary.fifo; unlink temporary.fifo"'
PS: you probably don't want to use poWaitOnExit in either scenario
PPS: if you don't expect the user to have root rights all the time, providing your own programm that calls tail on the correct file and set the setuid bit on this file as root. This needs to be done only once (on installation of your program) and then this program always runs with root previliges regardless which user calls it
PPPS: sudo might not be installed on all linux systems, just keep that in mind