1
votes

I am struggling with jmeter for running cmd command to remote desktop. I use the OS sampler. I have a command that if I run it from the command line from my computer it worked, but when I try to make jmeter to run it, it failed - I use the same computer. the command is:

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

I added an OS sampler as followed: enter image description here

the working directory is the cmd.exe directory. and the command is the full command I want jmeter to run, the same one that working perfectly on cmd direct.

I get this error:

Response message: Exception occurred whilst executing system call: java.io.IOException: Cannot run program "plink -ssh [email protected] -pw passtest  sudo /opt/test/test.sh" (in directory "c:\windows\system32"): CreateProcess error=2, The system cannot find the file specified

I do not know which file jmeter wants, I just want him to run the command, to connect to remote computer and run the command, the command working perfectly in command line and run the script in the remote computer.

I found this blog in the net: https://www.blazemeter.com/blog/how-run-external-commands-and-programs-locally-and-remotely-jmeter

that said that it can be done, but since it is easy they not displayed step by step instructions.

when I change the command to dir, it run OK and the results are like I write dir in command line.

How can I make jmeter open the command line and just put the command and press enter, and display the results?

1

1 Answers

3
votes

In the command you need to give the name of the programme to execute. In case of command prompt it is cmd.exe and for shell i think it is powershell.exe Rest need to be pass as command parameters.

Check below for command parameters:-

The OS Process Sampler is a sampler that can be used to execute commands on the local machine. It should allow execution of any command that can be run from the command line. Validation of the return code can be enabled, and the expected return code can be specified. Note that OS shells generally provide command-line parsing. This varies between OSes, but generally the shell will split parameters on white-space. Some shells expand wild-card file names; some don't. The quoting mechanism also varies between OSes. The sampler deliberately does not do any parsing or quote handling. The command and its parameters must be provided in the form expected by the executable. This means that the sampler settings will not be portable between OSes.

Many OSes have some built-in commands which are not provided as separate executables. For example the Windows DIR command is part of the command interpreter (CMD.EXE). These built-ins cannot be run as independent programs, but have to be provided as arguments to the appropriate command interpreter.

For example, the Windows command-line: DIR C:\TEMP needs to be specified as follows:

Command: CMD Param 1: /C Param 2: DIR Param 3: C:\TEMP

If the commands are remote commands then try with "Remote Commands: Linux/MacOSX" with SSH sampler shown in the blog you shared.

Below screenshot for simple execution of dir command:-

enter image description here enter image description here

--update-- additional screenshots

to execute a windows commad DIR c:\test use below settings

enter image description here