petervojtek / cordova-plugin-shell-exec

Apache Cordova Plugin to Execute Commands in Smartphone's Operating System Shell
Apache License 2.0
34 stars 17 forks source link

Read de external Storage sdcard #3

Open maxlinux2000 opened 8 years ago

maxlinux2000 commented 8 years ago

Hi

I'm tring to read (and then write) the sdcard using:

    <script>
    function lsfuncion() {
        window.ShellExec.exec('ls /sdcard/', function(res){
          console.log('exit status: ' + res.exitStatus)
          console.log('cmd output: ' + res.output)
//          alert(res.output)
            var div = document.getElementById("COMMAND");
            div.textContent = res.output;
            var text = div.textContent;
        })
    }    
    </script>
<div id="wrapper">
<p><a href="#" class="btn" onclick="lsfuncion();">$ ls /sdcard</a></p>
</div>  
<div id="COMMAND"></div>

but the result is: "Process has not yet termintated: 3577" ...that sound like the plugin can not read an external device mounted in the filesystem.

no problem if we try to read de root /

Can have a look for it, please?

petervojtek commented 8 years ago

honestly I have no idea how access rights are set on android on the /sdcard dir.

However from apk itself you definitely can read and write sdcard, at least I have experience doing it via cordova file plugin.

From this table it seems that <sdcard>/ dir is both r/w, but maybe <sdcard>/ dir is actually some subdir of your /sdcard/.

gardner commented 8 years ago

You'd want to add the Android permission for storage and files: WRITE_EXTERNAL_STORAGE