Execute an external application as root - problem
Posted
by
user598011
on Stack Overflow
See other posts from Stack Overflow
or by user598011
Published on 2011-02-01T07:13:52Z
Indexed on
2011/02/01
7:25 UTC
Read the original article
Hit count: 152
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.
© Stack Overflow or respective owner