title: Executing script via Android app
body: <p>I have an Android app that I have installed as a system application (in /system/app) which is meant to execute a shell script passing a few variables that that user has set from within the app.
  The code I am using is:</p>
  
  <pre><code>public void onClick(View v) {
  
                          try{
                              Log.i("MyActivity", "trying");
                              Process su = Runtime.getRuntime().exec("su");
                              DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
  
                              outputStream.writeBytes("busybox chroot /uoa /bin/createuser.sh " + username.getText().toString() + " " + password.getText().toString());
                              outputStream.flush();
  
                              outputStream.writeBytes("exit\n");
                              outputStream.flush();
                              su.waitFor();
                          }catch(IOException e){
                              Log.e("MyActivity", e.toString());
                          }catch(InterruptedException e){
                              Log.e("MyActivity", e.toString());
                          }
              } 
  </code></pre>
  
  <p>However I get an error:</p>
  
  <blockquote>
    <p>E/MyActivity( 1872): java.io.IOException: write failed: EPIPE (Broken
    pipe)</p>
  </blockquote>
  
  <p>And the script does not get executed. I know the script works as I can run the command via adb shell.</p>
  
  <blockquote>
    <p>busybox chroot /uoa /bin/createuser.sh testuser test</p>
  </blockquote>
  
  <p>Also how can I get the output from the script to log? </p>