4

I have a file StockExchangeData.txt in my remote server. I am trying to get it to my local drive C:\User\KD\ExchangeData using WinSCP (FTP).

In my SSIS, I have an "Execute Process Task". In its Process tab, I am using Executable as C:\Program Files (x86)\WinSCP\WinSCP.exe. What shall I use in the arguments section to complete the download from remote server to my local drive?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Kuldip.Das
  • 191
  • 1
  • 3
  • 13

1 Answers1

2

To automate a download using WinSCP, use its scripting interface.

The simplest FTP download script specified on a command-line is like:

/log=c:\path\to\log\winscp.log /command "open ftp://username:password@example.com/" "get /path/to/file.ext C:\User\KD\ExchangeData\" "exit"

Replace the username, password and example.com with the actual connection details. Use real paths.

For details see the guide to automating file transfers from SFTP/FTP server using WinSCP.

You can also move the script commands to a separate script file to shorten the command-line parameters list.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Am I supposed to use the above command line in the argument section in the execute process task???? – Kuldip.Das Dec 01 '15 at 07:00
  • can you please explain the part - /log=c:\path\to\log\winscp.log. Are we doing a session logging here? – Kuldip.Das Dec 01 '15 at 07:22
  • Yes, it's for session logging. It's essential as you have no other way to debug any issues. – Martin Prikryl Dec 01 '15 at 07:26
  • One more question, what does the following do - V_FTP_COMMAND = C:\Program Files (x86)\WinSCP\WinSCP.exe ; exec ('[V_FTP_COMMAND]' , '/ console/ script=' || '[servername]' || '\StockExchangeData.txt',0) – Kuldip.Das Dec 01 '15 at 07:38
  • Thank you very much for your support. I am starting to understand the solution now. – Kuldip.Das Dec 01 '15 at 07:44
  • @Martin Prikryl -- I need small help. How can we download the all files available in folder with some specific name using same above logic.. for example I wish to download all the files having name like.. starting with name as ABC_ – vikrant rana Jun 18 '19 at 08:53
  • @vikrantrana Please post your question as an actual separate question. This is not a chat. This is Q&A site. – Martin Prikryl Jun 18 '19 at 08:56
  • @ Martin Prikryl.. I have placed a question.. not able to connect to winscp server itself. https://stackoverflow.com/questions/56650179/file-transfer-using-execute-process-task-in-ssis – vikrant rana Jun 18 '19 at 13:25