0
votes

I am facing an issue in jmeter that I want to know if I can solve. I need to run a script in distance computer. when I run the script via command line in my computer it is working.

plink -ssh [email protected] -pw passtest  sudo /opt/test/test.sh

I want to run it in Jmeter from my computer (the same as the script run). I tried the ssh sampler that did not work I want to useage the OS sampler, Is it can be done? Can I run script on distance computer? The only explanation I found was from blazemeter site, and mentioned: "Again, since running the “plink” program via the OS Process Sampler is quite easy,"

remote machine: [email protected],
password for remote machine: passtest,
command: sudo /opt/test/test.sh

So can someone please advise

I added the OS sampler

enter image description here

and get this message:

Exception occurred whilst executing system call: java.io.IOException: Cannot run program "sudo /opt/test/test.sh" (in directory "plink -ssh [email protected] -pw passtest "): CreateProcess error=267, The directory name is invalid

Can someone please advise how to run the command in the remote computer? once again if I take the full line into command command line it is working, but after I cut it for Jmeter it is not working? what am I missing

1

1 Answers

1
votes
  1. Command arguments need to go in the "Command parameters" section, not in the "Working Directory"
  2. I would suggest running your script via cmd.exe interpreter, so the actual command would be cmd, not the Linux command
  3. It is more safe to provide -hostkey parameter as if the remote Linux machine is not in known_hosts your script will get stuck

    Assuming all above your OS Process Sampler configuration should look like:

    JMeter OS Process Sampler for plink


It might be easier to use JSR223 Sampler where you can invoke a program and get the output as easy as:

"c:\somefolder\plink.exe -pw passtest sudo /opt/test/test.sh".execute().text

More information on the approach: Apache Groovy - Why and How You Should Use It