shell - 脚本文件执行正常,但在 SSIS 中使用 WinSCP 失败

标签 shell ssis sftp winscp

我正在使用(或尝试)WinSCP 与公共(public) SFTP 服务器进行通信以下载不同的数据。完美的场景是我使用 SSIS 从 SFTP 下载最新的文件,但我无法从使用 WindowsPowershell 运行的 Winscp.net 获取示例。

因此,另一个解决方案是运行一个简单的脚本来下载所有 zip 文件。这是我所拥有的,并且在执行时可以单独工作(.bat文件):

winscp.exe /console /command "option batch abort" "option confirm off" "open sftp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f5988ca0869087bb949890b5908d9498859990a6b3a1a5db969a98" rel="noreferrer noopener nofollow">[email protected]</a>" "get *.zip c:\" "exit"

当我尝试在执行进程任务中的 SSIS 中执行相同操作时,它失败并出现信息丰富的错误:

The process exit code was "1" while the expected was "0"

我已经尝试了 WinSCP.net 文档中的所有内容(我猜),但没有任何效果。还在 open 中指定了主机 key 命令但同样的失败。

以下是执行流程任务编辑器的屏幕截图: enter image description here

最佳答案

您正在尝试使 WinSCP 运行 Windows 批处理文件。它实际上意味着您正在要求 WinSCP 运行 WinSCP。这显然失败了。如果您尝试执行要求 SSIS 运行的命令,您会发现:

"C:\Program Files (x86)\WinSCP\WinSCP.exe" "/script=C:\Program Files (x86)\WinSCP\Script1.bat"

这可能输出类似:

Unknown command 'winscp.exe'


您需要将 WinSCP 参数从 Script1.bat 移至 SSIS Arguments 参数:

/console /command "option batch abort" "option confirm off" "open sftp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0b66725e786e79456a666e4b6e736a667b676e584d5f5b25686466" rel="noreferrer noopener nofollow">[email protected]</a>" "get *.zip c:\" "exit"

或者让您的 Script1.bat(然后您应该更改扩展名)包含 WinSCP 命令:

option batch abort
option confirm off
open sftp://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="375a4e6244524579565a5277524f565a475b52647163671954585a" rel="noreferrer noopener nofollow">[email protected]</a>
get *.zip c:\
exit

有关该主题的一般讨论,请参阅:

关于shell - 脚本文件执行正常,但在 SSIS 中使用 WinSCP 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21303885/

相关文章:

python - 从脚本获取与从 python shell 获取不同的电影信息

windows - 谷歌浏览器静默安装

svn - 如何从 svn 中删除 "-"文件?

ssis - 如何以编程方式在 SSIS 中使用 "Foreach From Variable Enumerator"创建 foreach 循环

java - 使用java将图像保存到SFTP服务器

linux - 需要使用 shell 脚本自动执行手动任务

sql - SSIS Oracle 显示数据但导入 NULL

ssis - ETL SSIS - 开始另一个步骤时包花费的时间太长

java - SFTP 下载未完成

sftp - 传输文件 SFTP 时的 Ctrl-M 字符