title: How to execute Python script from Java (via command line)?
body: <p>I can execute Linux commands like <code>ls</code> or <code>pwd</code> from Java without problems but couldn't get a Python script executed.</p>
  
  <p>This is my code:</p>
  
  <pre><code>Process p;
  try{
      System.out.println("SEND");
      String cmd = "/bash/bin -c echo password| python script.py '" + packet.toString() + "'";
      //System.out.println(cmd);
      p = Runtime.getRuntime().exec(cmd); 
      BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
      String s = br.readLine(); 
      System.out.println(s);
      System.out.println("Sent");
      p.waitFor();
      p.destroy();
  } catch (Exception e) {}
  </code></pre>
  
  <p>Nothing happened. It reached SEND but it just stopped after it...</p>
  
  <p>I am trying to execute a script which needs root permissions because it uses serial port. Also, I have to pass a string with some parameters (packet).</p>