BookmarkSubscribeRSS Feed
Eshan
Calcite | Level 5

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://user:password@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


2 REPLIES 2
snoopy369
Barite | Level 11

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).
Eshan
Calcite | Level 5

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


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!

How to Concatenate Values

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.

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