title: IOException using exec, or defaultexecutor in java
body: <p>Exception</p>
  
  <pre><code>/usr/sbin/asterisk -rx "dongle sms dongle0    km FROM&gt; some address TO&gt; some address 20 kms. Please respond in 2 minutes, ok, yes, 1 or book. Else ignore"
  java.io.IOException: Cannot run program "/usr/sbin/asterisk -rx "dongle sms dongle0 " (in directory "."): java.io.IOException: error=2, No such file or directory
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:488)
      at java.lang.Runtime.exec(Runtime.java:610)
      at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
      at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:254)
      at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:319)
      at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
      at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
      at Test.main(Test.java:33)
  Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
      at java.lang.UNIXProcess.&lt;init&gt;(UNIXProcess.java:164)
      at java.lang.ProcessImpl.start(ProcessImpl.java:81)
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:470)
      ... 7 more
  </code></pre>
  
  <p>Code</p>
  
  <pre><code>public static void main(String[] args) {
          CommandLine commandLine = new CommandLine("/usr/sbin/asterisk -rx \"dongle sms dongle0 ");
          DefaultExecutor executor = new DefaultExecutor();           
          String cmd[] = new String[8] ;
          cmd[0] = "" ; // phonenumber
          cmd[1] = "" ; // distancefrom customer 
          cmd[2] = "km FROM&gt;" ;
          cmd[3] = " some address " ;
          cmd[4] = " TO&gt;" ;
          cmd[5] = " some address ";
          cmd[6] = "20" ;
          cmd[7] =  "kms. Please respond in 2 minutes, ok, yes, 1 or book. Else ignore\"";
  
          try {               
              for (int i = 0 ; i &lt; cmd.length ; i++)
                  commandLine.addArgument(cmd[i], false) ;
              System.out.println(commandLine.toString());
              executor.execute(commandLine);
          } catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  </code></pre>
  
  <p>I have tried</p>
  
  <blockquote>
    <blockquote>
      <p>CommandLine commandLine = new CommandLine("/bin/sh -c echo  | sudo /usr/sbin/asterisk -rx \"dongle sms dongle0 "); I get the EXACTLY same exception for /bin/sh</p>
      
      <p>CommandLine commandLine = new CommandLine("/bin/dash -c echo  | sudo /usr/sbin/asterisk -rx \"dongle sms dongle0 "); I get the EXACTLY same exception for /bin/dash</p>
    </blockquote>
  </blockquote>