title: Unable to execute shell script via java servlet
body: <p>I'm trying to execute a simple shell script via java servlet using process builder and I'm not getting any output. I searched for number of solution on stack overflow but nothing helped me out yet...
  Here is my code that I'm trying to execute..</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form method="post" action="SmxServlet"&gt;
      &lt;input type="submit" value="Click"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Shell script:</p>
  
  <pre><code>echo Hello world!, here your args $@ &gt; log.html 2&gt;&amp;1
  </code></pre>
  
  <p>SmxServlet.java:</p>
  
  <pre><code>public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          response.setContentType("text/html");
          String[] command = {"/bin/bash", "test.sh", "Argument1"};
          ProcessBuilder p = new ProcessBuilder(command);
          Process p2 = p.start();
          try {
              p2.waitFor();
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          BufferedReader br = new BufferedReader(new InputStreamReader(p2.getInputStream()));
          String line;
  
          System.out.println("Output of running " + command + " is: ");
          while ((line = br.readLine()) != null) {
              System.out.println(line);
          }
          //RequestDispatcher dispatcher = request.getRequestDispatcher("log.html");
          //dispatcher.forward(request, response);
      }
  </code></pre>
  
  <p>As out put in console, I'm getting below with no value: </p>
  
  <pre><code>Output of running [Ljava.lang.String;@77f03096 is: 
  </code></pre>
  
  <p>Can anyone out there please help with this? Is there anything that I'm doing wrong?How to fix it? Really appreciate your help!</p>