0

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
1
  • Try monitoring to output of the Run command: result = wsh.Run(... then If result<>0 Then MsgBox "Error: " & result Commented Sep 17, 2015 at 0:28

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

This worked perfectly. Thank you so much for teaching me this!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.