title: Running Linux command from Java - runtime.exe
body: <p>I'm trying to run the following command using Java runtime:</p>
  
  <pre><code>find /home/Alison/workspace/FunctionalTestFramework/src/com/q1labs/qa/selenium/screens -type d |   awk -F/ 'NF &lt;= old_NF {print prev} {old_NF=NF; prev=$0} END {print $0}'
  </code></pre>
  
  <p>The command works fine when entered directly into a Terminal but when ran in the following function it gives the following error:</p>
  
  <pre><code>find: paths must precede expression: |
  Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
  Process exitValue: 1
  </code></pre>
  
  <p>The Java function:</p>
  
  <pre><code>     try
          {            
              Runtime rt = Runtime.getRuntime();
              Process proc = rt.exec("find /home/Alison/workspace/FunctionalTestFramework/src/com/q1labs/qa/selenium/screens -type d |   awk -F/ 'NF &lt;= old_NF {print prev} {old_NF=NF; prev=$0} END {print $0}'");
              InputStream stderr = proc.getErrorStream();
              InputStreamReader isr = new InputStreamReader(stderr);
              BufferedReader br = new BufferedReader(isr);
              String line = null;
              while ( (line = br.readLine()) != null)
                  System.out.println(line);
              int exitVal = proc.waitFor();
              System.out.println("Process exitValue: " + exitVal);
          } catch (Throwable t)
            {
              t.printStackTrace();
            }
  </code></pre>