DATA Step, Macro, Functions and more

Unable to download a csv file from WinSCP ftp server to local drive

Reply
Occasional Contributor
Posts: 12

Unable to download a csv file from WinSCP ftp server to local drive

Hi there,

I am using the following code to login to winscp ftp server and download one csv file into my network drive.

So, I am not sure where i am doing mistake.

If anybody knows, please suggest.

then I am submitting the following 2 lines of SAS Code.

%let dest = \\folder1\users\files\indata

%sysexec "C:\WinSCP\WinSCP.exe" /console /script:"&dest\FTP.txt" /command "get file1.prn &dest\file1.prn" "close" "exit";

FTP.txt file has the following code.

option batch on

option confirm off

open sftp://userSmiley Tongueassword@xx.x.xxx.xx.22

cd /a/b/c/csvfiles

But when i run the above code i am not getting the file into my local drive.

Any help will be appreciated.

Eshan


Super Contributor
Posts: 253

Re: Unable to download a csv file from WinSCP ftp server to local drive

You don't give us much to go on (like, how doesn't it work?)  Steps to troubleshoot this:

  • First, test the command line text in the command line by typing it by hand.  See if that gets your file.  If not, it's a WINSCP problem (either ftp.txt or something else is wrong).
  • Then, see what string is actually getting passed into %sysexec.  Instead of %sysexec'ing it, %let it to a macro variable, and %put that.  If that has errors, fix them.
  • Once it does not have errors, if the program still doesn't work, take the %put result and copy/paste it into CMD.  See if that works.  If not, see where it's different from your typed in code from the first step.  Consider the possibility of invisible characters (like 'A0'x ) causing trouble.
  • If it's the same code but it still doesn't work when %sysexec'ed but does work when pasted into CMD, then you may have some issues with %sysexec.  It's possible it's not permitted on your SAS server (it's often disabled).
Occasional Contributor
Posts: 12

Re: Unable to download a csv file from WinSCP ftp server to local drive

Posted in reply to snoopy369

Thanks Snoopy for your reply.

I just realized that i do not have winscp installed in my system. So, I think i can't  download the file from the ftp server. I think this could be the blocker.

The other thing is like you said i am trying to login to the sftp server from CMD in the following way.

sftp username@ipaddress

it prompted me to enter the password and i entered the password

But it says Permission denied<publickey, keyboard-interactive> along with a popup mesaage which says "SSH error occured, please contact administrator".

Snoopy, since you checked my code in %sysexec, do you think the sytax is correct. The purpose is i am trying to download a file from the ftp server into my dest path.

is the get command correct? if yest then i will try to install winscp and then i will try to run it and see how it goes.

The other important thing is the username and password that i am using are not mine, my team member provided his details for me to complete this task. I don't know how this affects.

In my code, in the ftp.txt, do i have to add the port(22) also to the server at the end.?

If you provide some clarification on my questions, it would really make me understand the whole process.

Thanks again.

Eshan


Ask a Question
Discussion stats
  • 2 replies
  • 903 views
  • 0 likes
  • 2 in conversation