2
votes

Does anybody knows how to execute series of commands over SSH from Jmeter. I used SSH Sampler as mentioned on http://www.technix.in/execute-linux-command-shell-script-apache-jmeter/#comment-8456 and was able to login to remote server with my own user. However, I want to do few more steps. Not sure how I can do

  1. Sudo to a different user – ‘sudo su – report’
  2. Change to some directory
  3. Run some shell script which is already there
  4. The Shell script will produce some output file. I need to SFTP the output file from there to local Jmeter directory

  5. Write some tests to verify the output file. THis can be done later but how to do first 4 steps.

The main problem I am facing is that I am not able to understand how I can run series of commands in SSH Sampler. I tried using ; and it worked. However I am not able to do Sudo and run shell script from there.

Any help would be much appreciated.

Cheers! Vivek

1

1 Answers

2
votes

As per su command manual

  -c, --command=command
          Pass command to the shell with the -c option.

So you can substitute sudo with su and execute something like:

su -c "cd /some/directory && ./run_some_script" -s /bin/bash report

See How to Run External Commands and Programs Locally and Remotely from JMeter guide for more information.