title: Java runtime exec with scp command
body: <p>This is a part of my code to copy files from local to a remote machine</p>
  
  <pre><code>try {
  Process cpyFileLocal = Runtime.getRuntime().exec("scp  " + rFile+"*.csv"     + " root@" + host + ":" + lFile);
  InputStream stderr = cpyFileLocal.getErrorStream();
  InputStreamReader isr = new InputStreamReader(stderr);
  BufferedReader br = new BufferedReader(isr);
  String line = null;
  System.out.println("&lt;ERROR&gt;");
  while ((line = br.readLine()) != null) {
  System.out.println(line);
  }
  System.out.println("&lt;/ERROR&gt;");
  int exitVal = cpyFileLocal.waitFor();
  System.out.println("Process exitValue: " + exitVal);
  System.out.println("...." + cpyFileLocal.exitValue());
  System.out.println("SCP COMMAND  "+"scp "+rFile+"*.csv" +"  root@"+host+":"+lFile);
  System.out.println("Sending  complete...");
  } catch (Exception ex) {
  ex.printStackTrace();
  }
  </code></pre>
  
  <p>the output is...</p>
  
  <pre><code>&lt;ERROR&gt;
  
      /opt/jrms/rmsweb/transfer/cn00/outgoing/*.csv: No such file or directory
      &lt;/ERROR&gt;
  
      Process exitValue: 1
  
      ....1
  
      SCP COMMAND  scp /opt/jrms/rmsweb/transfer/cn00/outgoing/*.csv root@10.50.1.29:/opt/jrms/transfer/incoming/
  </code></pre>
  
  <p>but when I run the command in terminal on the local machine, it works fine
  and when I run <strong>ll</strong> the files are there</p>
  
  <p>-rwxr-xr-x 1 freddie freddie  140 Apr 22 09:13 gc00cn00150420092629.csv*</p>
  
  <p>-rwxr-xr-x 1 freddie freddie  105 Apr 22 09:13 gc00cn00150420122656.csv*</p>
  
  <p>Any help please</p>