无法发送文件到 SFTP 服务器

问题描述 投票:0回答:0

我正在尝试使用 Excel 中的 VBA 宏自动将文件发送到 SFTP 服务器。我写了这段代码:

Sub SFTPUpload()
Dim winscpExePath As String
    Dim sftpHost As String
    Dim sftpUser As String
    Dim sftpPass As String
    Dim hostKey As String
    Dim sftpKeyPath As String
    Dim sftpRemotePath As String
    Dim sftpLocalPath As String
   
    winscpExePath = "C:\Program Files (x86)\WinSCP\WinSCP.com"
    sftpHost = "eu-sftp.apps.airliquide.com"
    'sftpHost = "10.152.50.112"
    sftpUser = "al-ald-prod"
    sftpPass = "ssh-rsa 2048 91:cd:88:de:53:93:f7:6d:2f:47:c2:8f:e9:a1:e5:ce"
    sftpKeyPath = "C:\Users\brice.tikiabane\Desktop\SFTP keys - Copie\al-ald-prod-2023-03-01-private_key.ppk"
    sftpRemotePath = "/al-gio-sftp-giocentralbatchprod-s-8ab50e07929c4a698/al-ald-prod/"
    sftpLocalPath = "C:\Users\brice.tikiabane\Documents\ALDE file.txt"
    
    Shell winscpExePath & " /command " & _
        """open sftp://" & sftpUser & "@" & sftpHost & " -privatekey=""" & sftpKeyPath & """ -hostkey=""" & hostKey & """" & _
        " """ & sftpRemotePath & """ " & _
        "put """ & sftpLocalPath & """ " & _
        "exit"""
        MsgBox "Sending successful"


End Sub

即使我成功到达“发送成功”,当我在 WinSCP 上检查目标 SFTP 服务器的内容时,我也没有看到我一直试图发送到任何地方的文件。

你有什么建议吗?我仔细检查了源路径和远程路径。还有其他功能可以用于发送吗?

感谢您的帮助和支持

我尝试将文件发送到 SFTP 服务器。运行该功能后,显示“发送成功”,这意味着我已经顺利完成了该功能的结尾,但是当我使用 WinSCP 检查其内容时,目标服务器中没有留下任何文件

excel vba powershell sftp winscp
© www.soinside.com 2019 - 2024. All rights reserved.