Reputation: 193
So I have code that creates a sequence of steps in a text file in the temp directory and then executes the shell FTP. The question I have is, once the shell is launched and is running through the FTP, is it possible to log the FTP results? Like if a file failed to upload or "can't find file name" etc? This way I can be away from the computer while the script is pushing files to the FTP and later look at the log to see what failed and why.
This is my FTP launch command:
Sub executeFTPBatch(ByVal ftpfileName)
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
wsh.Run "FTP -i -s:C:\Temp\" & ftpfileName & ".txt", 1, True
End Sub
Upvotes: 0
Views: 1263
Reputation: 202642
Redirect the output of the ftp.exe
to a file:
wsh.Run "%comspec% /c FTP -i -s:C:\Temp\" & ftpfileName & ".txt > c:\path\ftp.log 2>&1", 1, True
See also https://ss64.com/nt/syntax-redirection.html
Upvotes: 3