通过SSIS连接到SFTP

五月

我正在尝试SFTP通过SSIS软件包连接到服务器程序包WinSCP使用.txt文件中的以下连接字符串执行

open sftp://username:fc$#[email protected]:22

但是,该软件包一直无法连接而失败。与密码中的特殊字符有关吗?

如果替换字符串,则可以连接到其他SFTP,所以我知道它一定与上面的语法有关。我尝试如下将双引号引起来,但没有成功:

open "sftp://username:fc$#[email protected]:22"
湿婆

对于最近的一个工作项目,我也必须这样做。我们在WinSCP .NET assembly内部使用了SSIS脚本任务,因为这也是WinSCP推荐的,它是在SSIS中使用WinSCP实现SFTP的方法。

请参阅本指南-使用SQL Server Integration Services(SSIS)中的WinSCP .NET程序集它引导您完成安装和设置,并包含有效的示例代码(当然,在您更改脚本后!)。

下面是示例代码(在引用WinSCPnet.dll程序集之后)

using System;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.ScriptTask;
using System.AddIn;
using WinSCP;

namespace ST_5a30686e70c04c5a8a93729fd90b8c79.csproj
{
    [AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : VSTARTScriptObjectModelBase
    {
        public void Main()
        {
            // Setup session options
            SessionOptions sessionOptions = new SessionOptions
            {
                Protocol = Protocol.Sftp,
                // To setup these variables, go to SSIS > Variables.
                // To make them accessible from the script task, in the context menu of the task,
                // choose Edit. On the Script task editor on Script page, select ReadOnlyVariables,
                // and tick the below properties.
                HostName = (string) Dts.Variables["User::HostName"].Value,
                UserName = (string) Dts.Variables["User::UserName"].Value,
                Password = (string) Dts.Variables["User::Password"].Value,
                SshHostKeyFingerprint = (string) Dts.Variables["User::SshHostKeyFingerprint"].Value
            };

            try
            {
                using (Session session = new Session())
                {
                    // As WinSCP .NET assembly has to be stored in GAC to be used with SSIS,
                    // you need to set path to WinSCP.exe explicitly, if using non-default location.
                    session.ExecutablePath = @"C:\winscp\winscp.exe";

                    // Connect
                    session.Open(sessionOptions);

                    // Upload files
                    TransferOptions transferOptions = new TransferOptions();
                    transferOptions.TransferMode = TransferMode.Binary;

                    TransferOperationResult transferResult;
                    transferResult = session.PutFiles(@"d:\toupload\*", "/home/user/", false, transferOptions);

                    // Throw on any error
                    transferResult.Check();

                    // Print results
                    bool fireAgain = false;
                    foreach (TransferEventArgs transfer in transferResult.Transfers)
                    {
                        Dts.Events.FireInformation(0, null, 
                            string.Format("Upload of {0} succeeded", transfer.FileName),
                            null, 0, ref fireAgain);
                    }
                }

                Dts.TaskResult = (int)DTSExecResult.Success;
            }
            catch (Exception e)
            {
                Dts.Events.FireError(0, null,
                    string.Format("Error when using WinSCP to upload files: {0}", e),
                    null, 0);

                Dts.TaskResult = (int)DTSExecResult.Failure;
            }
        }
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

通过域而不是IP连接到SFTP失败

来自分类Dev

用户无法通过SFTP连接到/ var / www / html /

来自分类Dev

如何通过sftp连接到Midnight Commander上的非标准端口?

来自分类Dev

如何使用SSH密钥通过Paramiko连接到SFTP-Pageant

来自分类Dev

如何通过sftp连接到Midnight Commander上的非标准端口?

来自分类Dev

使用“连接到服务器”通过SFTP连接以访问远程服务器中的文件夹

来自分类Dev

使用phpseclib将PHP连接到SFTP

来自分类Dev

使用sftp连接到“基于TLS的FTP”

来自分类Dev

使用phpseclib将PHP连接到SFTP

来自分类Dev

Nautilus无法连接到SFTP共享

来自分类Dev

将FileZilla连接到SFTP,OpenSSH

来自分类Dev

SSIS动态连接到源和目标。

来自分类Dev

连接到Excel Source的SSIS错误

来自分类Dev

从ssis连接到azure服务总线队列

来自分类Dev

从 SSIS 连接到 Azure 服务总线

来自分类Dev

通过SSL连接到MySQL

来自分类Dev

通过PhpStorm连接到PostgreSQL

来自分类Dev

通过代理连接到Dropbox

来自分类Dev

通过中间SSH的FileZilla SFTP连接

来自分类Dev

通过两层sftp与Thunar连接

来自分类Dev

通过SSIS,无法使用已成功连接并且在ODBC.INI注册表中的用户DSN连接到mysql DB

来自分类Dev

使用JSch连接到SFTP时如何选择网络接口

来自分类Dev

无法将sftp连接到ubuntu服务器

来自分类Dev

使用JSch连接到SFTP时如何选择网络接口

来自分类Dev

sftp-如何连接到非默认端口?

来自分类Dev

如何使用提供的SSH密钥连接到SFTP?

来自分类Dev

使用SFTP连接到SoftLayer ObjectStorage时遇到问题

来自分类Dev

在 Dolphin 中连接到 FTP/SFTP 或传输 Nautilus 书签

来自分类Dev

Java尝试通过退出连接到MQ

Related 相关文章

热门标签

归档