1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
Sub TU_SftpPut()
Dim pUser As String
Dim pPass As String
Dim pHost As String
Dim pRemotePath As String
Dim fileToSendPath As String
Dim Putty_pscp_path As String
Putty_pscp_path = "C:\toto\UtilitairesNecessaires\pscp.exe"
fileToSendPath = "C:\toto\test.txt"
pUser = "rzerze"
pPass = "zerydfg"
pHost = "ftp.rzarerzerze.fr"
pRemotePath = "/home/rzarerzerze/www/test/"
SftpPut Putty_pscp_path , fileToSendPath, pUser, pPass, pHost, pRemotePath
MsgBox "Upload terminé !", vbInformation
End Sub
Public Sub SftpPut(Putty_pscp_path As String, fileToSendPath As String, pUser As String, pPass As String, pHost As String, pRemotePath As String)
Dim strCommand As String
Dim resultShell As Double
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim errorCode As Long
Dim waitOnReturn As Boolean: waitOnReturn = True
strCommand = Putty_pscp_path & " -sftp -l " & pUser & " -pw " & pPass & _
" " & fileToSendPath & " " & pHost & ":" & pRemotePath
Debug.Print strCommand
errorCode = wsh.Run(strCommand, vbNormalFocus, waitOnReturn)
If errorCode = 0 Then
MsgBox "Done! No error to report."
Set wsh = Nothing
Else
MsgBox "Program exited with error code " & errorCode & "."
Set wsh = Nothing
End If
End Sub |
Partager