So, I need to copy a file to /system
, and have to use shell commands, because the application is not running with enough privileges (and is not even installed to /system/apps at that time) - so its impossible to write to /system
directly.
String cmd = String.format("\"/bin/sh -c \'cp %s %s'", tempPath, out);
p = Runtime.getRuntime().exec(new String[] { "su", "-c", cmd });
However, SuperSU
pop-up informs me, that following application was granted to run as root:
/bin/sh -c _cp %s %s_
.
So ' are replaced with _, and eventually command takes no effect.
What is a proper way to run a command having so much quotes ("" and '' for a single argument to su
)?
I know of using su
's stdin to run commands separated by \n
, but it seems to be having its own problems (and was not working too).