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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| Public Function GoOn()
'Path and Name of file to FTP
Dim strPath
Dim strFileName
Dim ftpServer
Dim strUserName
Dim strPassword
Dim RepSever
Dim ExpWin
GoOn = False
Set ExpWin = New clsWindowsExporer
strPath = "c:\DezipFtp\"
ExpWin.Creer_Repertoires strPath
strFileName = strPath & "test.csv"
' FTP Server Settings
ftpServer = "Test.fr"
strUserName = "Testr"
strPassword = "123456789"
RepSever = "/ftp-Test/MyRep/Test"
' Exécution des commandes FTP :/TestFtpRd
GoOn = FTP_Data(strPath, strFileName, ftpServer, strUserName, strPassword, RepSever)
ExpWin.Supprimer_Fichier strPath & "StartFtpOk.txt"
End Function
'Permet de temporiser le traitement pour attendre la fin de l'exécution d'une tache :
Sub Tempo(T, F)
Dim d
Dim a
d = Now
a = 0
While DateDiff(F, d, Now) < T
a = a + 1
Wend
End Sub
Function FTP_Data(strPath, strFileName, ftpServer, strUserName, strPassword, RepSever)
Dim pFile
Dim ExpWin
Set ExpWin = New clsWindowsExporer
FTP_Data = False
'Création de la commande d'exécution de récupération du fichier (eclenchement.txt)
ExpWin.Supprimer_Fichier strPath & "FTP_cmd_Get.txt"
ExpWin.FichierLog strPath & "FTP_cmd_Get.txt", "user" & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Get.txt", strUserName & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Get.txt", strPassword & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Get.txt", "CD " & RepSever & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Get.txt", "Get " & strFileName & " " & strPath & strFileName & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Get.txt", "Close" & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Get.txt", "quit" & vbCrLf
'Création du fichier Bat de réception FTP
ExpWin.Supprimer_Fichier strPath & "FTP_Run_Get.bat"
ExpWin.FichierLog strPath & "FTP_Run_Get.bat", "ftp -n -s:" & Chr(34) & strPath & "FTP_cmd_Get.txt" & Chr(34) & Space(1) & ftpServer & vbCrLf
ExpWin.FichierLog strPath & "FTP_Run_Get.bat", "Del " & strPath & "Go.txt" & vbCrLf
'Execute FTP command
Dim Shell
Set Shell = WScript.CreateObject("WScript.Shell")
Shell.Run (strPath & "FTP_Run_Get.bat")
TesteFichier strPath & "FTP_cmd.txt", False
'Création de la commande d'exécution de d'envoi des fichiers vers le serveur FTM (eclenchement.txt, dump_ibis.mdb)
ExpWin.Supprimer_Fichier strPath & "FTP_cmd_Put.txt"
ExpWin.FichierLog strPath & "FTP_cmd_Put.txt", "user" & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Put.txt", strUserName & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Put.txt", strPassword & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Put.txt", "CD " & RepSever & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Put.txt", "Put " & Chr(34) & strFileName & Chr(34) & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Put.txt", "Close" & vbCrLf
ExpWin.FichierLog strPath & "FTP_cmd_Put.txt", "quit" & vbCrLf
'Création du fichier Bat de réception FTP
ExpWin.Supprimer_Fichier strPath & "FTP_Run_Get.bat"
ExpWin.FichierLog strPath & "FTP_Run_Get.Put", "ftp -n -s:" & Chr(34) & strPath & "FTP_cmd_Put.txt" & Chr(34) & Space(1) & ftpServer & vbCrLf
'Execute FTP command
Set Shell = WScript.CreateObject("WScript.Shell")
Shell.Run (strPath & "FTP_Run_Put.bat")
Set Shell = Nothing
End Function |
Partager