title: Java throws Process exitValue: 127 when running expect script
body: <p>I'm trying a new approach to a hitch I've been stuck on.  Instead of using expect4j for my SSH connection, (I couldn't figure out a way past blocking consumer runs and issues with closures, see past posts for more info on that if you're knowledgeable and feeling saintly,) I'm going to try to use an expect script.  I have a runtime exec coded in to a button.onclick, see below.  Why am I getting a 127 exit value?  I basically just need this expect script to ssh in, run a single set of expect and send, give me the readout, and that's it...</p>
  
  <p>I'm using cygwin.  Not sure if that's relevant to why this isn't working...is my sh-bang line pointing to the right place?  My cygwin install is a full install, all packages, in C:\cygwin.</p>
  
  <p>Why am I getting a 127 exit value instead of a readout from my server, and how do I alleviate this?</p>
  
  <pre><code>try
      {            
          Runtime rt = Runtime.getRuntime();
          Process proc = rt.exec( new String [] {"C:\\cygwin\\bin\\bash.exe", "C:\\scripts\\login.exp"});
          InputStream stdin = proc.getInputStream();
          InputStreamReader isr = new InputStreamReader(stdin);
          BufferedReader br = new BufferedReader(isr);
          String line = null;
          System.out.println("&lt;OUTPUT&gt;");
          while ( (line = br.readLine()) != null)
              System.out.println(line);
          System.out.println("&lt;/OUTPUT&gt;");
          int exitVal = proc.waitFor();            
          System.out.println("Process exitValue: " + exitVal);
      } catch (Throwable t)
        {
          t.printStackTrace();
        }
  
  
  
  
  
  
  
  #!/usr/bin/expect -f
  spawn ssh userid@xxx.xxx.xxx.xxx password
  match_max 100000
  expect "/r/nDestination: "
  send -- "xxxxxx\r"
  expect eof
  </code></pre>