Hi
I am trying to send a file to a customer via FTP - using 2 methods but both return errors. Please help!
Method 1:
filename infile '/sas/lsf/Cred/Test_File.xls';
filename outdir ftp '/Data_Test' DIR FILEEXT
host="199.22.128.58"
user="tfgftp"
pass="abc123"
port=22;
/**********************************************************************/
data _null_;
infile infile truncover;
input;
file outdir(Test_File.xls);
put _infile_;
run;
Log:
NOTE: The infile INFILE is:
Filename=/sas/lsf/Cred/Test_File.xls,
Owner Name=darrylla,Group Name=sas,
Access Permission=-rw-rw-r--,
Last Modified=02Jun2016:13:40:05,
File Size (bytes)=66048
NOTE: SSH-2.0-CoreFTP-0.3.3
ERROR: Invalid reply received from FTP server..
NOTE: 0 records were read from the infile INFILE.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 1:03.37
cpu time 0.01 seconds
How do I resolve this error? I can login to the FTP site using FileZilla (ftp client software) so the user login details are valid.
Method 2:
Generating a sftp.cmd file.
curl -v -k --ftp-ssl-ccc -T /sas/lsf/Cred/Test_File.xls ftp://tfgftp:abc123@199.22.128.58:22/Data_Test 2>&1 | tee /sas/lsf/Cred/Logs/sftp.log
Log
NOTE: The infile DO_SFTP is:
Pipe command="/sas/lsf/Credico/Logs/sftp.cmd"
NOTE: 8 records were read from the infile DO_SFTP.
The minimum record length was 22.
The maximum record length was 5002.
NOTE: DATA statement used (Total process time):
real time 1:03.40
cpu time 0.02 seconds
sftp logfile
* Trying 199.22.128.58...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 199.22.128.58(199.22.128.58) port 22 (#0)
< SSH-2.0-CoreFTP-0.3.3
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0
writes out multiple lines untill the connection is closed.
0 0 0 0 0 0 0 0 --:--:-- 0:01:01 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:01:02 --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:01:03 --:--:-- 0* response reading failed
* Closing connection 0
curl: (56) response reading failed
CoreFTP is Windows-only, so it seems your target system is Windows. You will need to use correct file syntax for this.
But the kicker is that you specified port 22 (SSH) in a filename ftp. Omit specifying a port number so that SAS will use the correct port for FTP (21).
Thanks for the info Kurt.
I have used the first option before for another project and it worked. ie copying a file from a Unix location to a FTP site. The client has setup their ftp connection on port 22......
You mentioned CoreFTP. Do you have file syntax for this?
Regarding file syntax: since you have to deal with a Windows system, use C:\...\...\... instead of /.../.../...
Unless CoreFTP is set up so that it can translate UNIX-style paths to something sensible within the Windows filesystem.
But I still state that port 22 is reserved for the Secure Shell protocol, and the FTP Access Method simply won't work.
If someone else actually set up a standard (unencrypted, non-secure!) FTP server to run on port 22 (probably to trick their way around firewalls that only allow secure connections), their Information Security Officer should have a most severe talk with them 😞
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.