I can use Runtime.exec()
to execute shell commands like "getprop
" and "ls system
" and they work fine.
However, when I use "echo $BOOTCLASSPATH
", "echo \\$BOOTCLASSPATH
" or "echo HelloWorld
", it won't show it in stdout.
The logcat shows:
I/AndroidRuntime( 4453): VM exiting with result code -1.
Here's my code:
try {
java.lang.Process proc = Runtime.getRuntime().exec("echo -e \\$BOOTCLASSPATH");
String line = null;
InputStream stderr = proc.getErrorStream();
InputStreamReader esr = new InputStreamReader (stderr);
BufferedReader ebr = new BufferedReader (esr);
while ( (line = ebr.readLine()) != null )
Log.e("FXN-BOOTCLASSPATH", line);
InputStream stdout = proc.getInputStream();
InputStreamReader osr = new InputStreamReader (stdout);
BufferedReader obr = new BufferedReader (osr);
while ( (line = obr.readLine()) != null )
Log.i("FXN-BOOTCLASSPATH", line);
int exitVal = proc.waitFor();
Log.d("FXN-BOOTCLASSPATH", "getprop exitValue: " + exitVal);
} catch (Exception e) {
e.printStackTrace();
}