JMeter執行dos命令


1.通過java代碼實現

參考Java實現操作dos命令

2.直接通過JMeter內置的beanshell腳本操作

String command = "cmd /c start ping www.baidu.com";
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);

 

 

方式2:

Runtime rt = Runtime.getRuntime();  
Process pr = rt.exec("cmd /c ping www.baidu.com && dir");
//Process pr = rt.exec("D:\\xunlei\\project.aspx"); 
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream(), "GBK"));  
String line = null;  
     while ((line = input.readLine()) != null) {  
       System.out.println(line);  
  }  
int exitVal = pr.waitFor();  
System.out.println("*******success*******"+exitVal);  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM