javashelljmeteribm-cloudibm-cloud-tools

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


My code here, I want to ececute jmeter shell command in IBM cloud through Java.

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);
    }

Solution

    1. You need to launch jmeter.sh script instead of jmeter, it performs environment check, sets up variables, JVM options when it comes to Java 9, etc.
    2. You need to ensure that both jmeter.sh and jmeter have execute permissions, i.e. execute the following command:

      chmod +x /JMeter/apache-jmeter-4.0/bin/jmeter && chmod +x /JMeter/apache-jmeter-4.0/bin/jmeter.sh
      
    3. I don't think you need these dots in your command, to wit you need to amend your command to look like:

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

    More information: Five Ways To Launch a JMeter Test without Using the JMeter GUI