I'm tring to run this:
String[] hin1 = { "su", "-c",
"mount -o remount,rw -t yaffs2 /dev/block/mtdblk3 /system" };
try {
Runtime.getRuntime().exec(hin1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] hin2 = { "su", "-c", "m /system/etc/hosts" };
try {
Runtime.getRuntime().exec(hin2);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] hin = { "su", "-c",
"cp /sdcard/hosts /system/etc/" };
try {
Runtime.getRuntime().exec(hin);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Sadly it is only working when I make for every action a new button.. :(
Is there a way to run more than one command at once??
Thanks
Depending on how the su command is implemented (ie, if it's launching something approaching a capable shell as it would on a more typical linux), you may be able to combine multiple commands into one string by separating them with semicolons.
You could also make a shell script containing multiple commands and use su to launch that, though you may need to put it in an executable location.
Don't think so its working also , I tried the following code :
only button for command su -c chmod 777 dev/test1 (for changing the permission of one log file in dev directory) but it didn't work. Whats wrong in this.Can some one point out whats missing. I have even put this line in the Androidmanifest.xml as well
Rgds, Saurabh
You're not letting one command finish before the next one starts. Try adding a waitFor after the exec: