Groovy调用smbclient进程无法从Jmeter工作

时间:2018-12-13 09:54:03

标签: groovy jmeter

我正在尝试使用以下脚本通过smbclientjmeter执行groovy命令

String command = 'smbclient -U user%pass //100.97.59.95/Shares -c "scopy  download\\\\temp.zip test.zip"'

    OUT.println('Command to run: '+command)
    def sout = new StringBuilder(), serr = new StringBuilder()
    def proc_update = command.execute()
    proc_update.consumeProcessOutput(sout, serr)
    proc_update.waitFor()
    println("command ouput :")
    println "out> $sout err> $serr"

下面是回溯

File to copy: temp.zip
Command to run: smbclient -U user%pass//100.97.59.95/Shares -c "scopy  download\temp.zip test.zip"
command ouput :
out> scopy <src> <dest>
 err> WARNING: The "syslog" option is deprecated
Domain=[WIN-VLTIKCNNV6P] OS=[Windows Server 2012 Datacenter 9200] Server=[Windows Server 2012 Datacenter 6.2]

该命令在我的终端上正常运行,而不是在Groovy上。可能是什么原因?

1 个答案:

答案 0 :(得分:0)

建议尽可能使用JMeter内置测试元素作为none of available scripting engines provides the same performance as Java code,所以我建议改用OS Process Sampler。相关配置如下:

  • 命令:<link href='@Url.Content("~/Content/site.css")' rel="stylesheet" type="text/css" />
  • 参数1:/bin/bash
  • 参数2:-c

enter image description here

您将能够像其他任何采样器一样查看/获取STDOUT / ERR输出,即,您可以使用View Results Tree侦听器对其进行可视化:

enter image description here