Pankaj Harde
Pankaj Harde

Reputation: 55

Issue in executing a sequence of linux commands using Jmeter installed on a linux VM

Hope you are doing great.

I am reaching out to the community as I am currently stuck with a problem of executing a sequence of commands from a linux machine using jmeter.

A bit of Background:-

I have an external VM which is used to mimic the transfer of file to various inbound channels. This VM is basically acting as a third party which hosts files which are then transferred to different location by following a sequence of commands

The Sequence of Commands that I am trying to execute to mimic the third party are as below

  1. ls (to list the files in the Home Dir)

  2. mv test123.txt test456.txt (This renames the file in the home Dir from test123.txt to test456.txt)

Then we connect to the File exchange server using the command below

  1. sftp -P 24033 [email protected]
  2. password is test@123456

Once Connected we execute the below sequence

  1. ls(This will list folders Inbound or Route)
  2. CD Route (To change Dir to Route)
  3. ls (List the account ID's)
  4. put test456.txt 12345 (12345 is the account ID)

Post the execution of the last command the file is transferred to internal folder based on account ID

I did some search on stack over flow and found a couple of links but was not able to make successful use of it to simulate the above sequence of commands

The closest one I could find is as below

How to execute Linux command or shell script from APACHE JMETER

But this does not talk about executing from a linux machine itself

Any help on how to approach this one will help me out. Thanks in advance

PS:- I am using jmeter cause I have to keep this sequence executing continuously till I transfer the expected number of file in a peak hour durations and these files are of different sizes ranging from few MB's to a couple of GB's

New Edit

I used the JSR223 Pre-Processor where I have my sequence of commands and then I call that command in the OSS Sampler and created a script as below

enter image description here

enter image description here

The script executes on the Linux box without any error but the file is not transferred to the destination. Am I missing something?

On some research I did found an lftp command but not sure how to use in my case and if that will work or not.

Any suggestions?

Upvotes: 0

Views: 185

Answers (1)

Dmitri T
Dmitri T

Reputation: 168082

  1. To execute commands on local Linux machine you can use OS Process Sampler

  2. To execute commands on remote Linux machine you can use SSH Command Sampler

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

  3. To transfer the file from local to remote you can use SSH SFTP Sampler

In order to get SSH Command and SSH SFTP Samplers install SSH Protocol Support plugin using JMeter Plugins Manager:

enter image description here

Upvotes: 1

Related Questions