运行 IBM 云中的 shell 命令通过 java 程序抛出错误 java.io.IOException:无法 运行 程序 =13,权限被拒绝

Running a shell command in IBM cloud through java programme throwing error as java.io.IOException: Cannot run program =13, Permission denied

我这里的代码,我想通过Java在IBM云中执行jmetershell命令。

Runtime run = Runtime.getRuntime();
Process pr = run.exec("./JMeter/apache-jmeter-4.0/bin/jmeter -n 
-t ./JMX/"+FileName+" -l ./JTL/Generate_Dashboard.jtl -e -o 
./Result/"+Name+""");
pr.waitFor();
BufferedReader buf = new BufferedReader(new 
InputStreamReader(pr.getInputStream()));
String line = "";
while ((line=buf.readLine())!=null) {
        System.out.println(line);
    }
  1. 您需要启动 jmeter.sh 脚本而不是 jmeter,它会执行环境检查、设置变量、JVM options 当涉及到 Java 9 等。
  2. 需要保证jmeter.shjmeter都有execute permissions,即执行如下命令:

    chmod +x /JMeter/apache-jmeter-4.0/bin/jmeter && chmod +x /JMeter/apache-jmeter-4.0/bin/jmeter.sh
    
  3. 我认为您的命令中不需要这些点,也就是说您需要将命令修改为:

    Process pr = run.exec("/JMeter/apache-jmeter-4.0/bin/jmeter -n -t /JMX/"+FileName+" -l /JTL/Generate_Dashboard.jtl -e -o /Result/"+Name+""");
    

更多信息:Five Ways To Launch a JMeter Test without Using the JMeter GUI