我想将脚本从第一个.sh
文件复制到另一个文件。但是在.sh
执行文件时会说Read-only file system
。
在第一个.sh文件中,这是脚本
echo "echo "|=================--=================|"" > /system/0211/0211syscheck.sh
echo "echo "|====================================|"" > /system/0211/0211syscheck.sh
我尝试将复制脚本复制到文件/system
夹内的文件中
挂载/system
ReWritable
:
mount -o rw,remount,rw /system
和ReadOnly
:
mount -o ro,remount,ro /system
您也可以将其用于其他目录。
PS:这些命令用于linux terminal
。
这是在android上执行此代码的示例代码:
//your command
String[] commandrw = {"mount -o rw,remount,rw /system"};
//cmds = your command;
public boolean RunAsRoot(String[] cmds){
Runtime runtime = Runtime.getRuntime();
Process process;
try {
for (String cmd : cmds) {
process = runtime.exec(new String[] {"su", "-c", cmd});
if (process.waitFor() != 0) {
// Command failed
return false;
}
}
} catch (Exception e) {
return false;
}
return true;
}
//put this code in a buttonclick or oncreate etc...
RunAsRoot(commandrw); //replace commandrw with your command
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句