ProcessBuilder throwing java.lang.Exception: -


i trying figure out why code below throwing

java.lang.exception: no such file or directory

exception

        processbuilder send = new processbuilder("/bin/bash","/opt/ftp/scripts/xfer.sh | /opt/ftp/myftp -c /opt/ftp/ftp.conf >> /logging/ftp.log2>&1");         process sendprocess = send.start();         br = new bufferedreader(new inputstreamreader(sendprocess.geterrorstream()));         builder = new stringbuilder();         line = null;         while ( (line = br.readline()) != null) {            builder.append(line);            builder.append(system.getproperty("line.separator"));         }         if(!builder.tostring().isempty()){             throw new exception( "error xfer.sh: "+builder.tostring() );         }    

i've tried isolating arguments within string array, did not work either. ideas may causing stacktrace?

i have success using following code. maybe have use -c option:

private static int execute(string command) {     runtime runtime = null;     process process = null;      int exitvalue = -1;     bufferedinputstream bis = null;      try {         runtime = runtime.getruntime();          process = runtime.exec(new string[] { "/bin/bash", "-c", command });         bis = new bufferedinputstream(process.getinputstream());          byte[] b = new byte[1892];         while (bis.read(b) != -1) {         }          exitvalue = process.waitfor();          if (bis != null) {             try {                 bis.close();             } catch (ioexception e) {             }         }         if (process != null) {             process.destroy();         }     } catch (exception e) {         //logging     }      return exitvalue; } 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -