I try to launch a command from Java in Linux with sudo
and I can't find a way. I have tried the following, but... although from the terminal it works, from the execution of my program it does not.
public Boolean activarServicio(){
lanzarComando();
Boolean finaly = false;
try{
if(!estado){
consola2=Terminal.lanzarComando("teamviewer --daemon enable");
//consola2=Terminal.lanzarComando("echo mipassword | sudo -S teamviewer --daemon enable");
finaly = true;
}
}catch(IOException err){
}
return finaly;
}
Does anyone have any idea how to solve this?