How to use 'OS Sampler' of jmeter to run any command of terminal on ubuntu

MUSADDIK :

I want to change system date using terminal from j-meter for which i am using "OS sampler".

I want to run: 'sudo date --set "2015-09-30 10:05:59.990"' command in terminal using OS sampler.

But it is not working.

Under OS sampler fields i have tried - 'nohup' in command box, '/home/test4' in working directory field, and 'sudo date --set "2015-09-30 10:05:59.990"' in command parameters.

click here for screenshot

Please correct me what wrong i am doing?

MUSADDIK :

Got the solution!!!

Create one bash file and write below command

echo -e "(password_of_your_system)\n" | sudo -S date --set "2020-03-09 07:00:00"

Click here for bash file screenshot

Save the bash file and move the file to the location where you jmx file is saved.

Now go to jmeter >> OS Sampler and do the settings as displaying in below screenshot.

Click here for OS Sampler settings

Command: /bin/bash

Working dir: Path of your jmx file.

Command parameter: your bash file with extension .sh

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=345989&siteId=1