Read command output inside su process

Ok, I’ve found a solution. It should look like this: Process p = Runtime.getRuntime().exec(new String[]{“su”, “-c”, “system/bin/sh”}); DataOutputStream stdin = new DataOutputStream(p.getOutputStream()); //from here all commands are executed with su permissions stdin.writeBytes(“ls /data\n”); // \n executes the command InputStream stdout = p.getInputStream(); byte[] buffer = new byte[BUFF_LEN]; int read; String out = new String(); //read … Read more

Running Shell commands though java code on Android?

To run root commands, you have to use the flllowing format: public void RunAsRoot(String[] cmds){ Process p = Runtime.getRuntime().exec(“su”); DataOutputStream os = new DataOutputStream(p.getOutputStream()); for (String tmpCmd : cmds) { os.writeBytes(tmpCmd+”\n”); } os.writeBytes(“exit\n”); os.flush(); } where you pass in an array of strings, each string being a command that needs to be executed. For example: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)