DATA Step, Macro, Functions and more

Error with getting a file from ftp site

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Error with getting a file from ftp site

Hi,

 

I have a problem with retriving a file from ftp site. From the details in log, I'm able to connect to the site and get to the target folder. However it failed to establish the connection to the file that I'd like to download. Could anyone have any ideas about this issue?

 

My code: 

 

filename inv ftp 'inventory.csv'
host = 'xxxxxxxx'
user = 'xxxxxxx'
pass = 'xxxxxxxx'
port = ###
/*wait_milliseconds=1000000*/
cd = '/Download/'
recfm=s

debug;

 

filename lcl 'C:\Users\Downloads\inv.csv' recfm = n;


data _null_;
N=1;
infile inv NBYTE=N;
input;
file lcl;
put _infile_ @@;
run;

 

 

The log is:


NOTE: 220 (vsFTPd 3.0.2)
NOTE: <<< 220 (vsFTPd 3.0.2)
NOTE: >>> USER xxxxxx
NOTE: <<< 331 Please specify the password.
NOTE: >>> PASS XXXXXXXXXX
NOTE: <<< 230 Login successful.
NOTE: >>> OPTS UTF8 ON
NOTE: <<< 200 Always in UTF8 mode.
NOTE: >>> OPTS UTF8 NLST
NOTE: <<< 501 Option not understood.
NOTE: >>> OPTS UTF-8 NLST
NOTE: <<< 501 Option not understood.
NOTE: >>> PORT 10,16,20,27,237,200
NOTE: <<< 200 PORT command successful. Consider using PASV.
NOTE: >>> TYPE I
2 The SAS System 16:03 Friday, September 22, 2017

NOTE: <<< 200 Switching to Binary mode.
NOTE: >>> CWD /Download/
NOTE: <<< 250 Directory successfully changed.
NOTE: >>> PWD
NOTE: <<< 257 "/Download"
NOTE: >>> RETR inventory.csv
NOTE: <<< 425 Failed to establish connection.
ERROR: Invalid Reply received for the RETR command..
NOTE: UNBUFFERED is the default with RECFM=N.

 

 

Thank you in advance!


Accepted Solutions
Solution
‎09-26-2017 05:08 PM
Super User
Posts: 9,866

Re: Error with getting a file from ftp site

Try to use the PASSIVE option in filename ftp. This option was introduced with 9.3.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Super User
Posts: 3,853

Re: Error with getting a file from ftp site

If you try to retrieve this file using the FTP command at a Windows command line then manually typing your instructions does it work OK?

New Contributor
Posts: 4

Re: Error with getting a file from ftp site

I have difficulties to login the ftp site using command line. However, I can easily open the ftp site and download the file from it. 

Solution
‎09-26-2017 05:08 PM
Super User
Posts: 9,866

Re: Error with getting a file from ftp site

Try to use the PASSIVE option in filename ftp. This option was introduced with 9.3.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
New Contributor
Posts: 4

Re: Error with getting a file from ftp site

Posted in reply to KurtBremser

Thank you! The problem solved by adding the passvie option in filename ftp.

Super User
Posts: 9,866

Re: Error with getting a file from ftp site


Lynn_SAS wrote:

Thank you! The problem solved by adding the passvie option in filename ftp.


To further elaborate, how standard FTP works:

The client opens a connection to the server and logs in. As soon as you start a download, your client opens a port on the local computer, sends the port number to the server, and starts to listen on that port. The server now becomes "active", and tries to open a connection to your client on that port for the file transfer; basically, for this operation your client becomes a server.

Since firewalls block open ports against the outside world, this fails. When the passive option is used, all connections are made with the FTP server being the listener ("passive") and your client opening the connection to that.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
New Contributor
Posts: 4

Re: Error with getting a file from ftp site

Posted in reply to KurtBremser

Thank you again for the further explaination!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 724 views
  • 1 like
  • 3 in conversation