SSIS 通过 WINscp 从SFTP下载文件

1.通过SSIS的process task调用 winscp :C:\Program Files (x86)\WinSCP\WinSCP.exe

                  /script="C:\SFTPFile\TEST.txt"

2.

编写winscp 代码:

 open sftp:// [ ueserid ] :[ password ] @10.ip :22
 get \PBI_landing_Zone\in\ANP\test.txt C:\
 exit
注意: 1.winscp 口令遇到内部关键字需要用转义字符代替(密码中有+ 需要用  %2B代替

  • space: %20 or +
  • #: %23 (number sign/hash)
  • %: %25 (percent sign)
  • +: %2B (plus sign)
  • /: %2F (slash)
  • @: %40 (at sign)
  • :: %3A (colon)
  • ;: %3B (semicolon)

    2.路径需要定位到最底层否则无法识别 通配符 *

 

3.BAT 文件调用winscp代码:

cd C:\Program Files (x86)\WinSCP
winscp.exe /console /command "option batch on" "option confirm off" "open sftp:// [ ueserid ] :[ password ];fingerprint=ssh-dss********-9d@10.[ip]:22" "option transfer binary" "cd \PBI_landing_Zone\in\ANP\" "get test* C:\ "

注意: BAT文件中转义字符是%,跟winscp冲突需要转义两次(比如 + 需要写成 : %%2B)

 

 

WINSCP 通配符 :https://winscp.net/eng/docs/library_wildcard

转义字符 : https://winscp.net/eng/docs/session_url

 

批处理文件特殊字符:http://www.bathome.net/thread-1224-1-1.html

 

 

 

  

 

posted @ 2019-05-31 16:12  ethan_song  阅读(1231)  评论(0编辑  收藏  举报