How can I run a linux command from an Android App and read the output. For example: retrieving output of "ls -lh" and printing as a text in TextView?
1 Answer
Try this:
try{
Process process;
process = Runtime.getRuntime().exec("ls -lh");
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
After this in post to your TextView.
1 Comment
bianca
I get this error: java.io.IOException: Error running exec(). Command Working Directory: null Environment: null. Any idea whats this?