processbuilder

Java ProcessBuilder: environment set correctly but still command not found

非 Y 不嫁゛ 提交于 2019-12-02 01:15:56
I am having troubles with Java's ProcessBuilder on an Eclipse plugin I'm developing. I correctly set the environment before calling the start() method, but when I run the program, it always returns a command not found error. When I call the command via command line it works perfectly. When I start the eclipse with the environment as I require, the command is found and the program works fine. Only when I set the environment programatically, the program fails. Here is what I have: ProcessBuilder pb = new ProcessBuilder("my_command", file, output); Map<String, String> env = pb.environment(); env

java Process' inputStream stuck

空扰寡人 提交于 2019-12-01 23:05:30
Here's my scenario: process A spawns child process B and spins threads to drain B's outputs. process B spawns daemon process C and drains its outputs, too. process B finishes, daemon process still lives. process A finds out that process B exited via process.waitFor(). However, it's stuck on reading the input streams of process B. It's because B has started a daemon. The input stream receives EOF only when the process C exits. This only happens on Windows. I'm using the ProcessBuilder. Here're the solutions I came up with and I'd like to hear your feedback as none of the solutions I really like

java Process' inputStream stuck

耗尽温柔 提交于 2019-12-01 22:08:46
问题 Here's my scenario: process A spawns child process B and spins threads to drain B's outputs. process B spawns daemon process C and drains its outputs, too. process B finishes, daemon process still lives. process A finds out that process B exited via process.waitFor(). However, it's stuck on reading the input streams of process B. It's because B has started a daemon. The input stream receives EOF only when the process C exits. This only happens on Windows. I'm using the ProcessBuilder. Here're

“find: missing argument to `-exec'” running in a Java process builder

耗尽温柔 提交于 2019-12-01 20:53:52
I am trying to run the find command inside Jenkins ( https://jenkins-ci.org ) script console, which allows running groovy scripts from a web interface. My code is: ProcessBuilder pb = new ProcessBuilder(); pb.directory(new File("/var/lib/jenkins/jobs/myJob"); pb.redirectOutput(ProcessBuilder.Redirect.INHERIT); pb.redirectError(ProcessBuilder.Redirect.INHERIT); command = 'find . -name build.xml -exec echo \"{}\" \\;' println(command) pb.command(command.split(" ")); pb.start().waitFor(); The web UI will display the result of println: find . -name build.xml -exec echo "{}" \; While the jenkins

Processbuilder without redirecting StdOut

耗尽温柔 提交于 2019-12-01 19:33:26
问题 Is it possible to redirect the output stream back into a process, or not redirect it at all? The backstory: I am trying to launch an executable using processbuilder. (Source dedicated server / srcds.exe to be exact) As a result of launching it with the processbuilder, the console window of this executable remains empty. A few seconds after launch, the executable crashes with the error "CTextConsoleWin32::GetLine: !GetNumberOfConsoleInputEvents" because its console is empty. 回答1: I think you

not able to execute R script from java program?

一个人想着一个人 提交于 2019-12-01 18:06:05
问题 I have a Rscript in a String variable and I want to execute it from Java program and pass some variable to it. If I execute that R script standalone, it works fine. I have converted that R script to one line by escaping it everything by using Python program as shown below: import json jsonstr = json.dumps({"script": """\ #!/usr/bin/Rscript # read the data file library('jsonlite') library('rpart') args <- as.list(Sys.getenv(c( "path", "client_users"))) if (args[["path"]]==""){ args[["path"]] <

not able to execute R script from java program?

左心房为你撑大大i 提交于 2019-12-01 17:59:57
I have a Rscript in a String variable and I want to execute it from Java program and pass some variable to it. If I execute that R script standalone, it works fine. I have converted that R script to one line by escaping it everything by using Python program as shown below: import json jsonstr = json.dumps({"script": """\ #!/usr/bin/Rscript # read the data file library('jsonlite') library('rpart') args <- as.list(Sys.getenv(c( "path", "client_users"))) if (args[["path"]]==""){ args[["path"]] <- "." } # other stuff here # other stuff here """}) print jsonstr I use the printed string out and

How to use exitValue() with parameter?

人走茶凉 提交于 2019-12-01 14:25:31
A very good article (When Runtime.exec() won't) says: The only possible time you would use exitValue() instead of waitFor() would be when you don't want your program to block waiting on an external process that may never complete. Instead of using the waitFor() method, I would prefer passing a boolean parameter called waitFor into the exitValue() method to determine whether or not the current thread should wait. A boolean would be more beneficial because exitValue() is a more appropriate name for this method, and it isn't necessary for two methods to perform the same function under different

ProcessBuilder cannot run python script with arguments

↘锁芯ラ 提交于 2019-12-01 12:56:44
Ok, so I have a python script that I am running through ProcessBuilder. Everything is working fine. The issue I am having is whenever I pass arguments into the python script, the python script responds with a unrecognized argumets . BUT if I take the exact command and copy and paste it into the command prompt, it runs perfectly fine. Any help? Here is the general idea of what I have right now: ProcessBuilder builder = new ProcessBuilder("C:\Python33\" + "python.exe","-u", "C:\...\script.py", "--arg1 " + "argumentValue"); p = builder.start(); Pass two separate arguments to ProcessBuilder

ProcessBuilder cannot run python script with arguments

纵然是瞬间 提交于 2019-12-01 12:01:14
问题 Ok, so I have a python script that I am running through ProcessBuilder. Everything is working fine. The issue I am having is whenever I pass arguments into the python script, the python script responds with a unrecognized argumets . BUT if I take the exact command and copy and paste it into the command prompt, it runs perfectly fine. Any help? Here is the general idea of what I have right now: ProcessBuilder builder = new ProcessBuilder("C:\Python33\" + "python.exe","-u", "C:\...\script.py",