Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 968 Bytes

README.md

File metadata and controls

46 lines (29 loc) · 968 Bytes

cordova-plugin-shell-exec

Apache Cordova Plugin to Execute Commands in Smartphone's Operating System Shell, in SuperUser (su) mode. Rooted device needed.

Supported Platforms

  • Android

Installation

$ cordova plugin add https://github.com/carlo318/cordova-plugin-shell-exec.git

Usage

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.

How to Contribute

Use pull request.