TransWikia.com

JMeter get the latest file / contents from SFTP folder

Stack Overflow Asked by JavaMan on November 4, 2021

I am trying to use JMeter to perform an end to end test. The test involves writing to SFTP folder and reading a file generated as a result of write operation from another SFTP folder.

I am able to connect to SFTP folder using JMeter SSH SFTP plugin and able to successfully write / read SFTP folder contents.

The application under test, creates an output file based on the input file (put by JMeter). The challenge now I have is to read the contents / file which is created on the SFTP folder.

The application under test writes a file with an date-time string which JMeter may not know hence I am trying to read the latest file.

The JMeter SSH SFTP plugin provides a number of options i.e. ls, rm, rmdir, etc however, I have chosen the edit option (${sftp username@servername 'ls -ltr /server/path | tail -n 1'}) and tried to use the following in order to read the file however, I neither see error nor response.

I would appreciate any pointers and if you can think of a better solution. Please also let me know if you would like me to share more information.

Thanks in advance.

One Answer

  1. You're using the wrong sampler, if you want to run a command you need (surprisingly) SSH Command Sampler
  2. This pipe symbol | is not a parameter for ls command, it's a part of Unix shell, in majority of cases it would be bash so you need to amend your command to look like:

    /bin/bash -c "ls -ltr /server/path | tail -n 1"
    

    example SSH Command Sampler configuration:

    enter image description here

    and example output:

    enter image description here

More information: How to Run External Commands and Programs Locally and Remotely from JMeter

Answered by Dmitri T on November 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP