A normal day of a Windows Sysadmin: You just want to upload some files with a small script to a ftp-server but the firewall in your site does not allow active ftp uploads. (Hint: The Windows build-in ftp.exe does only support active ftp connections.) So what to do?
Background: Active FTP vs Passive FTP
In active mode the client starts listening on a random free port. It informs the server on which port it is listening and is waiting for the connection. Normally the client is behind a firewall, so the incoming connection of the server will be blocked by default. In this situation you will not be able to connect with the ftp server and send your data.
In the passive mode the client tries to connect to the server and receives a IP address and a port from the server, to which the client can connect to. So the client initiates the data connection and should normally be able to send data to the ftp server.
Exception: If there are outgoing restrictions in your firewall - passive ftp will also not work. So you have to contact your firewall administrator.
The Answer: WinSCP
WinSCP - it allows scripting and the passive FTP mode. So you can automate the upload of generated files via the Windows Task Scheduler.
How to execute the script with WinSCP:
Simple script to connect to a ftp server and upload some file:
option batch on
option confirm off
open ftp://user:password@host -passive=on
option transfer binary
That's it. Small and simple.