DATA Step, Macro, Functions and more

Converting from FTP to SFTP

Reply
New Contributor
Posts: 4

Converting from FTP to SFTP

Is there anyone who has experience with converting from FTP to SFTP?

I need make the following code to work by using SFTP.

 

data scr;

Length x $100.;

x='OPEN ORA_WSMOD';                             output; /* FTP SERVER*/

x='xxxxx';                                output; /* USERNAME*/

x='xxxxxx';                               output;/* PASSWORD*/

x='cd ftp_out';                                 output; /* FTP-FOLDER*/

x='lcd c:\temp';                          output; /* OUTPUT FOLDER*/

x='PUT filename1.txt';               output; /* The filename */

x='PUT filename2.txt';              output; /* Another filename*/

x='quit';                           output;

run;

 

data _null_;

set  WORK.SCR                                     end=EFIEOD;

%let _EFIERR_ = 0;

%let _EFIREC_ = 0;

file 'c:\temp\scr.txt' delimiter='09'x DSD DROPOVER lrecl=32767;

format x $100. ;

if _n_ = 1 then

do;

end;

do;

EFIOUT + 1;

put x $ ;

;

end;

if _ERROR_ then call symput('_EFIERR_',1);

If EFIEOD then

call symput('_EFIREC_',EFIOUT);

run;

 

option XWAIT XSYNC;

X 'ftp -s:c:\temp\scr.txt';

Community Manager
Posts: 2,768

Re: Converting from FTP to SFTP

Is there a reason that you're not using FILENAME FTP?  That might be a little more straightforward to code.


There is also a method for FILENAME SFTP.  As this involves a secure connection, you need an SSH client. From the doc:

 

You must have the applicable client software installed to use the SFTP access method. The SFTP access method supports only the following SSH clients.

  • OpenSSH – UNIX
  • PUTTY – Windows

 

 

 

New Contributor
Posts: 4

Re: Converting from FTP to SFTP

Thank you very much for your reply,Chris.

 

I have just installed software Putty on my computer, Is there any special configuration that Putty should have before i can make SFTP to work?

 

Thanks a lot in advance.

New Contributor
Posts: 4

Re: Converting from FTP to SFTP

 

 

Maybe the SFTP server SAS is connecting to should also have software Putty in order to make my sas program working?

 

Community Manager
Posts: 2,768

Re: Converting from FTP to SFTP

You definitely need Putty to be installed wherever SAS is running, so if your SAS session is on a remote Windows machine, you'll need the SSH client to be there. 

 

I assume that whatever FTP endpoint you're connecting to is already running an SFTP server to support secure connections/transmissions.

New Contributor
Posts: 4

Re: Converting from FTP to SFTP

Thanks for your reply again, Chris.

 Is there any special configuration that Putty should have before i can make SFTP to work or i do not know if i have gotten the right version of Putty?

see the attached file( Putty configuration on my computer)

 

Best regards Mei

Community Manager
Posts: 2,768

Re: Converting from FTP to SFTP

 

Yes, there are a few steps -- since you asked, I decided to check in our SAS Tech Support notes.  I think that everything is documented here:

 

Configuring SSH Client Software in UNIX and Windows Environments for Use with the SFTP Access Method...

Ask a Question
Discussion stats
  • 6 replies
  • 122 views
  • 3 likes
  • 2 in conversation