Reputation: 41
I want to copy a script from the first .sh
file to another file. But when the .sh
file is executed, it say Read-only file system
.
Inside the first .sh file this is the script
echo "echo "|=================--=================|"" > /system/0211/0211syscheck.sh
echo "echo "|====================================|"" > /system/0211/0211syscheck.sh
I try this for copy script to a file inside /system
folder
Upvotes: 0
Views: 109
Reputation: 12571
Mount /system
ReWritable
:
mount -o rw,remount,rw /system
and ReadOnly
:
mount -o ro,remount,ro /system
you can also use it for other directories.
PS: these commands are for linux terminal
.
Here is a sample code to execute this code on 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
Upvotes: 1