BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Lynn_SAS
Fluorite | Level 6

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!

1 ACCEPTED SOLUTION
6 REPLIES 6
SASKiwi
PROC Star

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?

Lynn_SAS
Fluorite | Level 6

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. 

Lynn_SAS
Fluorite | Level 6

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

Kurt_Bremser
Super User

@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.

Lynn_SAS
Fluorite | Level 6

Thank you again for the further explaination!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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