When I execute the following command in the terminal, it executes as expected i.e. it displays the current folder contents.
echo <password> | sudo -u root -S ls
But if i execute the same command in my java application, its output is:
<password> | sudo -u root -S ls
How do I overcome this?
'|'. there are numerous answers already on SO and the web specifying how to do this.sh -c "echo sanovi | sudo -u root -S ls"instead?