Access files through FTP for particular date.

Is there any option in wM to get the files from a directory for a particular date(say 10th Feb) through FTP ?

As I found , the services are not having sufficient privileges to get the date wise files from Dir.

Please let me know if you have come across the same issue and found the solution .

Note - We have only FTP access to the directory.


Indeed, the standard pub.client.ftp:ls and pub.client.ftp:dir commands only return file names, no details on the files. You could try to accomplish your requirement using the pub.client.ftp:quote service. This service allows you to issue custom commands on the ftp server. You can issue a ls command with full details and parse the response the server returns.

Kind regards,


Hi Koen,

Thanks for the help. I will try with the option mentioned by you.

Hello Koen,

We tried pub.client.ftp:quote service with command ls -ltr but it returns error message

500: 'LS -ltr ': Command not understood.

We we tried using pwd command it returns the result.

Can you please give more insight about pub.client.ftp:quote service.



You’re right. the result for the LS command is returned via the data port, while the quote command does not use data connections. This causes the error (also if you issue a “quote ls” command from a command line ftp session).

More ideas anyone?

Kind regards,


This is just a workaround for the above problem .

While creating the file on the FTP server create it with date_stamp as filename prefix or suffix. List all the files with ‘ls’ or ‘cdls’ and then loop over the list and get only those that macthes the current date ( precalculated and stored in a string ) . OR You may use a filename filter with dates . While getting the file you may use seperate filename ( target filename ) to remove the date_time stamp.

This works good while fetching the files for current date or any date near to the current date .

Thanks Dhruv for the suggestion.

We cannot modify the file name according to date time stamp.
We are trying to implement pub.client.ftp:quote service passing the parameters LIST after PASV. It takes long time to reply back and gives output as ABOR i.e. abort from FTP.

Any idea on the this ? – anyone

Thanks in advance.


Another option I can think of is:

  • Create a .bat (or .sh) file that lists the files on the remote ftp server that logs the output to a file
  • Create a service in webMethods to parse the output file created by the script
  • Create a service to execute the OS batch file

Kind regards,


Thanks Koen for the suggestion.

Please let us know how to run the Shell script when we just have ftp access to that folder.



On windows, the following approach would work:

  • Create an ftp script (say, d:\ftpscript.txt) on the webMethods machine:
cd [folder]
ls -ltr
  • Create a batch file (say, d:\ftpls.bat) to execute the script on the webMethods machine:
FTP -v -s:ftpscript.txt [servername] >> d:\ftpoutput.txt
  • Create a Java service in webMethods to execute the script:
   Process proc = Runtime.getRuntime().exec("cmd /c d:\\ftpls.bat");
   int exitVal = proc.waitFor();
catch(Throwable t){
   throw new ServiceException(t);

Now if you call the service, the batch file will be executed on the webMethods machine. The batch file will log on to the remote ftp server (with the username and password from ftpscript.txt), change to the right directory and list the contents. The output of the ftp commands will be written to ftpoutput.txt.
When this service completes, you can read and parse the file ftpoutput.txt which contains the result of the ftp commands.

The same approach can be used on other platforms, but you will of course need to modify it accordingly.

Kind regards,


Thanks a lot Koen for a quick reply.