Apache Cordova Plugin to Execute Commands in Smartphone's Operating System Shell, in SuperUser (su) mode. Rooted device needed.
- Android
$ cordova plugin add https://github.com/carlo318/cordova-plugin-shell-exec.git
window.ShellExec.exec(cmd, callback)
cmd
must be a single string.
callback function will return a hash with two keys - exitStatus
and output
.
Example:
window.ShellExec.exec('am start -a android.intent.action.REBOOT', function(res){
console.log('exit status: ' + res.exitStatus)
console.log('cmd output: ' + res.output)
})
JS console output:
exit status: 0
cmd output: executed
If command execution fails (e.g. you enter wrong command), you receive exit status 100
.
The command is executed as superuser, following this suggestion.
Use pull request.