Execute an external application as root - problem
- by user598011
Good morning:
I'm trying to run an external application that needs to be executed
as root. I have to read the lines from exit after the execution
of this application but it says "permission denied", as if the
its not been done correctly. I've been thinking over a time
and I can not move forward. The code is as follows:
process = Runtime.getRuntime().exec("su");
String[] command = {external application command};
process = Runtime.getRuntime().exec(comando);
InputStream inputStream = process.getInputStream();
BufferedReader bufferedReader = null;
try
{
bufferedReader = new BufferedReader(new
InputStreamReader(inputStream),8192);
String line = null;
while ((line = bufferedReader.readLine()) != null)
{
System.out.println("read line:"+line );
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
process.waitFor();
Does anyone know why not let me run the command?
Thanks.