VBScript - copy local file to a FTPS TLS (implicit) server
I have a script that connects to a DataBase, executes a StoredProcedure,
saves the results into a normal TXT file, compresses the file into a *.rar
file (with a password) and sends the file by e-mail. Our client now wants
we to copy the file to his FTP server, instead of by e-mail.
The problem is that the connection type is implicit FTP over TLS.
I have the following script to test the file copy to an FTP:
'FTP Upload
Dim oShell, objFSO, ftpUser, ftpPass, ftpHost, ftpDir, path
Set oShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'FTP Server details:
ftpUser = "user"
ftpPass = "password"
ftpHost = "IP address:port"
ftpDir = "/FolderName/"
'File I want to upload:
path = "D:\test.txt"
Call FTPUpload(ftpUser, ftpPass, ftpHost, ftpDir, path)
Public Function FTPUpload(ftpUser, ftpPass, ftpHost, ftpDir, path)
'Upload a file to an FTP server
'Copy Options: 16 = Yes to All
Const copyType = 16
'FTP Wait Time in ms
waitTime = 80000
strFTP = "ftp://" & ftpUser & ":" & ftpPass & "@" & ftpHost & ftpDir
Set objFTP = oShell.NameSpace(strFTP)
'Upload single file
If objFSO.FileExists(path) Then
Set objFile = objFSO.getFile(path)
strParent = objFile.ParentFolder
Set objFolder = oShell.NameSpace(strParent)
Set objItem = objFolder.ParseName(objFile.Name)
objFTP.CopyHere objItem, copyType
End If
'Wait for upload
WScript.Sleep waitTime
End Function
This code works fine with a normal FTP (simple FTP connection), it copies
the file correctly, but with an implicit FTP over TLS connection I think
it doesn't even establish the connection.
With FileZilla I'm able to connect to that server and copy files, but I
want it to be automatic because it's a file we have to send every day.
When I open a Web browser and type ftp://[user]:[password]@host, it shows
me the folders in that FTP server, but with the implicit FTP it doesn't
work even on the web browser. Does it have a different syntax? I'v already
tried with ftps://, but it doesn't work either way.
Is there a way to copy a file to an implicit FTP over TLS using VBScript?
Thanks.
No comments:
Post a Comment