I try to debug a ProcessBuilder in Java. Is there a way to see the raw command that has been executed in a ProcessBuilder? I try to execute a curl command. How can I see the raw command?
I tried an error/output Stream, but that didn't produced any usefull output. Has anyone an idea off which stream I have to use?
StringBuilder builder = new StringBuilder();
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
while(line = input.readLine() != null){
builder.append(line);
builder.append(" ");
}
String result = builder.toString();
I also have tried this:
ProcessBuilder commandBuilder = new ProcessBuilder("curl", VOPT, AUOPT, AUV, AUT, URL, DURLE, PROJECTS, PID, DURLE, NOTES, NOTESVAL, DURLE, NAME, NAMEVAL);
Process command = commandBuilder.start();
Is there a property in the Process object where I can see the raw command?
Eventually, I have to simulate this command (the paramters are all correct in the ProcessBuilder):
curl -v -H "Authorization: Bearer <myPersonalToken>" https://app.asana.com/api/1.0/tasks --data-urlencode "projects=<projectId>" --data-urlencode "notes=PRTG_Message" --data-urlencode "name=8005"
ProcessBuilder has a 'command()' method which will give you back the argument list it will use to create the process. If you concatenate this with spaces, it should give you the resulting native command.
If that is not sufficient you could add && sleep 10000
and then check the running processes for the actual process being executed.