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!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1732 views
  • 0 likes
  • 2 in conversation