BookmarkSubscribeRSS Feed
vimal
SAS Employee
Dear ,

I am using this code to transfer a zip file from other server to sas sftp server.
But I am getting a corrupted file.
Please help me.

data _null_ ;
X 'umask 0000';
run;

x '@echo off';
x 'cd ';
x 'echo open > b.ftp';
x 'echo user user pwd >> b.ftp' ;

x "echo cd b.ftp";
x 'echo asc >> b.ftp';
x "echo get 6546_file.zip >> b.ftp";

x 'echo bye >> b.ftp ';
x 'ftp -ni <<destination_location>b.ftp > b.ftplog';

x 'echo bye';
3 REPLIES 3
DF
Fluorite | Level 6 DF
Fluorite | Level 6
You might try specifying binary transfer mode before moving any of the files? Just send the command "bin" in the same way you have done so for the others.
vimal
SAS Employee
Dear DF,

Can you please alloborate some more as I am a new to programming.
DF
Fluorite | Level 6 DF
Fluorite | Level 6
Sure - sorry if I was a bit too vague!

You have a line in your code that reads:

x 'echo asc >> b.ftp';

The "asc" tells FTP to transfer the file in ASCII mode. This works for text files like CSV or .tab, etc. and will automatically translate between Windows and UNIX text formats (for example).

However a ZIP file is not a text file, so this reformatting will corrupt the file. Try changing it instead to be:

x 'echo bin >> b.ftp';

That should tell it to copy in binary mode, and should hopefully stop your file corruption.

This article has some good notes on the subject: http://www.remote-control.net/articles/2006/ftp_notes/

Hope that helps!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1255 views
  • 0 likes
  • 2 in conversation