0
我試着在我的應用程序上運行Android上的python應用程序。
這個腳本工作正確的更好的終端模擬器臨Runtime.getRuntime().exec()工作不正確
su
busybox chroot /data/local/debian /bin/bash
/usr/bin/python /usr/src/script.py
然後我輸入值
>>value1
result
但是,如果我試圖在我的應用程序是:
String line;
Runtime.getRuntime().exec("su");
Runtime.getRuntime().exec("busybox chroot /data/local/debpsla /bin/bash");
Process proc = Runtime.getRuntime().exec("ls");
OutputStreamWriter osw = new OutputStreamWriter(proc.getOutputStream());
proc.waitFor();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
while ((line = bufferedReader.readLine()) != null){
publishProgress(line);
}
命令ls返回不正確的文件列表。這意味着根目錄不會更改。
我做錯了什麼?
謝謝!
我認爲你的答案可能並不清楚每次調用exec都會啓動一個新進程,因此與之前的調用無關。 – Zagrev 2013-03-09 20:40:16
我試過這個http://stackoverflow.com/a/3350862/2143772例子。但是chroot也沒有工作。 – 2013-03-10 10:31:10