Example 1 successfully executes but Example 2 does not. The reason is that a different Runtime.exec() method needs to be called in order to successfully invoke example 2 as explained in the stackoverflow post:
https://stackoverflow.com/a/25878208
Enhancement Request: Introduce two new methods in AQSystem:
runCommand(string[] cmdarray); Invokes Runtime.exec(String[] cmdarray)
runCommand(string[] cmdarray, folder); Invokes Runtime.exec(String[] cmdarray, null, dir)
Example 1:
importPackage(java.io); var cmd = aqua.getSystem(); var p = cmd.runCommand("/bin/bash -c 'env' 2>&1","/tmp"); var stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); var output = new Array; do { // read the output from the command line by line var outline = stdInput.readLine(); if(outline == null) { // no more data, stop break; } print (outline); output.push(outline); } while(true); stdInput.close() print ("Success");
Example 2:
importPackage(java.io); var cmd = aqua.getSystem(); var p = cmd.runCommand("/bin/bash -c 'env && echo' 2>&1","/tmp"); var stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); var output = new Array; do { // read the output from the command line by line var outline = stdInput.readLine(); if(outline == null) { // no more data, stop break; } print (outline); output.push(outline); } while(true); stdInput.close() print ("Success");
|
163 KB
I added these 2 OpenAPIs. Line 4 in Example 2 should be modified as below:
var p = cmd.runCommand(["/bin/bash", "-c", "env && echo", "2>&1"],"/tmp");
Verified that both Example 1 & Example 2 (modified, as stated here) product the desired output in 18.0.15-2. See SuccessfulExecution.png.
@qa: pls verify in v19
Verified that both Example 1 & Example 2 (modified, as stated here) product the desired output in 18.0.15-2. See SuccessfulExecution.png.
@qa: pls verify in v19
Issue #15322 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build 18.0.15-2, 19.0.0-alpha-48 |
No time estimate |
I added these 2 OpenAPIs. Line 4 in Example 2 should be modified as below: