Andy
Andy

Reputation: 221

jmeter execute complex shell command

Im using the OS Process Sampler to execute the following shell command

cat ${myDataFile} | myProcessor.sh --param1 valueParam1 --param2 valueParam2

command: cat 
Standard Input(stdin): ${myDataFile}
working directory: ${myHome}
command Parameters: | myProcessor.sh --param1 valueParam1 --param2 valueParam2

Response

cat: | myProcessor.sh --param1 valueParam1 --param2 valueParam2: No such file or directory

Clearly "cat" is tying to ca the command parameter as a file.

How to overcome this issue. This is running on a AWS EC2 environment

Upvotes: 0

Views: 598

Answers (2)

Dmitri T
Dmitri T

Reputation: 168002

  1. You need to pass your ${myDataFile} as a command Parameter, it shouldn't be simulating STDIN. See How to Run External Commands and Programs Locally and Remotely from JMeter article for more detailed explanation.
  2. If you want to use pipe you need to call your command via shell interpreter (sh, bash, zsh, whatever). Invoke echo $SHELL command and read man entries on your shell to learn how to do it.

Upvotes: 0

hek2mgl
hek2mgl

Reputation: 157937

If you are using a pipe |, you need to start the command in a shell:

bash -c "cat ${myDataFile} | myProcessor.sh --param1 valueParam1 --param2 valueParam2"

Your question leaves it open when ${myDataFile} will get expanded. I assumed it will get expanded by jmeter. If it should get expanded at runtime, you need to use single quotes:

bash -c 'cat ${myDataFile} | myProcessor.sh --param1 valueParam1 --param2 valueParam2'

Upvotes: 1

Related Questions