05-11-2016 12:11 AM
I want to copy a file from FTP server (Unix) to local machine (Windows) using SAS code.
There are many files loaded in FTP server daily. So, I want just to copy the latest file from FTP to local machine.
Currently, I have to manually copy from Unix server to Windows using FTP (Tectia).
05-11-2016 12:17 AM
If you can create a script on Windows or Unix side to do the job, its relatively easy to execute the script from SAS.
That's probably the ideal solution. You can also pass unix commands directly to the server or windows so if you can utilize x command you can pass the unix command to download the data as well.
In SAS 9.4+ there's FCOPY which will move files.
05-11-2016 12:33 AM
If possible, could you provide me unix code as i am not good with Unix.
So that I can make changes accordingly on that code and try it.
05-11-2016 12:36 AM
Sorry, I'm not great with Unix. It's also dependent on your application.
I'm sure if you searched on StackOverflow you'd find examples of what the commands should look like.
Would FCOPY work for you? Does your Base SAS see your server and your desktop at the same time? Or do you not have SAS 9.4?
05-11-2016 12:54 AM
Windows ftp can be scripted with the -s:scriptfile commandline option.
Since you will only use the Windows client, no UNIX knowledge apart from file/pathnames is required.
05-11-2016 12:42 AM
If you have EG you can use this add in:
PROC DOWNLOAD if you have the license for SAS/CONNECT
http://www2.sas.com/proceedings/sugi30/023-30.pdf (top of page 6)
Google search results (untested):
05-11-2016 05:26 AM
Why would you need to do it in SAS? You have an FTP program, just script it within that, then schedule that script to run as and when you need. Including another application (SAS) in the process just means another step which needs documenting, creating, and validating.
05-11-2016 05:37 AM
I agree with you RW9.
Even I tried the following code and create a batch of it for testing.
scpg3 host_server_name:/home/abcd/test.txt C:\abcd\Desktop
But, the issue is there are lot of files in the unix folder. I want the latest uploaded file only and with particular prefix.
Do you have any code for the same.
05-11-2016 06:43 AM
Thanks all for your help and quick responses.
I have prepared a scp command line code. Also, files which i wanted to download has date prefix.. so that will also help me to copy the desired files only.
THANKS ALL again for their valuable advice.
05-11-2016 05:59 AM
Its quite dependant on what you are using as the FTP software. I did it many years back in Reflections - VB scripting, so thats not going to be much help.
Google throws up a lot of results, this one for instance: