title: RE :How can we execute a shell script file from my Android Application
body: <p>I am trying to write an android application that runs a shell commands, or a shell script if that is preferable, and displays the output... can anyone give me in the right direction?</p>
  
  <p><strong>My code is as follows:</strong></p>
  
  <pre><code>void execCommandLine()
      {
          Runtime runtime = Runtime.getRuntime();
          Process proc = null;
          OutputStreamWriter osw = null;
  
          try
          {
  
              String[] str={"/system/bin/sh","/data/shTest.sh"};              
                   System.out.println("EXEC STRING");
                   proc = runtime.exec(str);
                 osw = new OutputStreamWriter(proc.getOutputStream());
              //osw.write(command);
              osw.flush();
              osw.close();
          }
          catch (IOException ex)
          {
                Log.e("erre","ioexception");          
              //Log.e("execCommandLine()", "Command resulted in an IO Exception: " + command);
              return;
          }
          finally
          {
              if (osw != null)
              {
                  try
                  {
                      osw.close();
                  }
                  catch (IOException e){}
              }
          }
  
          try 
          {
              proc.waitFor();
          }
          catch (InterruptedException e){}
  
          if (proc.exitValue() != 0)
          {
              Log.e("erre","interruotexception");         
              //Log.e("execCommandLine()", "Command returned error: " + command + "\n  Exit code: " + proc.exitValue());
          }
      }
       // **************************************
  </code></pre>
  
  <p>Code is running successfully but I am not getting any output in adb shell logcat 
  would anyone tell me if this script is executed successfully how to get this output 
  in Adb shell.</p>