How to get latest file from FTP server?

Reply
Occasional Contributor
Posts: 5

How to get latest file from FTP server?

Dear All,

I want to get latest file from a FTP server where i had many files. I am able to get the single file by giving the exact name of the file.

Is there any way to get Latest file.

Regards!!

Sandeep Sharma

Super Contributor
Posts: 578

Re: How to get latest file from FTP server?

Posted in reply to skbhardwaj89

This is how we do it.

filename fname ftp "actual_file_name.txt"

    host="xx.xxx.xxx.xxx"

    user='USERID'

    pass='PW'

    recfm=v

    LRECL=58

    rcmd='binary';

data WORK.current_scl;

    infile fname missover;

.

.

.

.

run;

Trusted Advisor
Posts: 3,215

Re: How to get latest file from FTP server?

The Ftp protocol has a lot of commands imbedded including directory commands.

SAS(R) 9.4 Statements: Reference  (Filename FTP)  See sample getting dir-listing

What is returned as listing is dependent of the server OS type and version.

As you have access to the file-server this can be tried.

Very often the FTP protocol is closed as thinking being harfull. SFTP is using the same approach. but then encrypted

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 2 replies
  • 400 views
  • 2 likes
  • 3 in conversation