User-agent: Mediapartners-Google Disallow: User-agent: * Disallow: /search Allow: / Sitemap: http://nano7mobile.blogspot.com/sitemap.xml Nano Mobile: Run su -c "command" process topic

Run su -c "command" process topic






I want to use su to launch a command and read its output.
I try this code:


Code:


          String line;
            Process cat=Runtime.getRuntime().exec("su -c \"cat /etc/media_codecs.xml\"");
            BufferedReader catStream= new BufferedReader(new InputStreamReader(cat.getInputStream()));
            BufferedReader catSerr= new BufferedReader(new InputStreamReader(cat.getErrorStream()));
            cat.waitFor();
            while((line=catSerr.readLine())!=null)
            {
                System.out.println(line);
            }
            while((line=catStream.readLine())!=null)
            {
                System.out.println(line);
            }


If I manually insert this command in the adb shell it works but with this code the phone ask me for root permission and If I accept I can read only this string to the stderr:
tmp-mksh: cat /etc/media_codecs.xml: not found
And there is not stdout code.

Why?

Thanks,
regards
A993






Aucun commentaire:

Enregistrer un commentaire