How to run from java-code command on Android?
cat /proc/kmsg > /mnt/sdcard/klog.log
It means, how should the line Runtime.getRuntime.exec()
look like?
The fact is that over-melting cannot be done. You can execute the command with arguments. So you have to do something like this.
Runtime.getRuntime().exec("/bin/sh -c 'cat /proc/kmsg > /mnt/sdcard/klog.log'");
UPD
Looks like I screwed up a bit too. Exec has some problem with executing commands with spaces in the arguments, so the code above will not work. I worked the following:
ProcessBuilder pb = new ProcessBuilder("/bin/sh", "-c", "cat /proc/kmsg > ~/kmem"); pb.start().waitFor();
Runtime.getRuntime().exec("cat /proc/kmsg > /mnt/sdcard/klog.log")
But, most likely, it can not be done without root privileges.
Source: https://ru.stackoverflow.com/questions/43555/
All Articles