Not sure this is the right place, but for the life...
# server
r
Not sure this is the right place, but for the life of me I cannot figure out what is going wrong with a command I am trying to run. I want to use the ProcessBuilder api to run a command, but it is erroring out. my code
Copy code
fun String.runCommand(workingDir: File): ProcessUtils.Result {
    val parts = this.split("\\s".toRegex())
    val proc = ProcessBuilder(parts)
      .directory(workingDir)
      .redirectOutput(ProcessBuilder.Redirect.PIPE)
      .redirectError(ProcessBuilder.Redirect.PIPE)
      .start()

    proc.waitFor(60, TimeUnit.SECONDS)
    val exitCode = proc.exitValue()
    val outputText = proc.inputStream.bufferedReader().readText().trim()
    return ProcessUtils.Result(exitCode, outputText)
  }
I have confirmed that
_workingDir.exists_() && _workingDir_._isDirectory_()
is true, but when the proc starts, it errors out with a dir not found error. Cannot fathom how the first statement can be true (confirmed dir does exist) but the proc cannot find it. My only guess is a permissions issue, but I cant find anything to confirm this is the case. Anyone have any ideas?
I see.. it's not talking about the directory, despite the error being
error=2, No such file or directory
... it's talking about the actual command