This page says that with some firewalls you should connect to the firewall and then connect to the host etc. Tried that, doesn't work.
I suspect that the problem is with the way in which php handles ftp commands. When a put command is sent on our system, cyberoam responds saying delayed due to scanning, and then uploads.
150-Scanning file for viruses
150-There'll be a delay while we scan for viruses
150 Data connection already open; Transfer starting.
221-Scanning for virus
221 Transfer complete.
I think php's ftp library does not handle the ftp 150 commands, hence it fails.
I have currently commented out the ftp upload part in the mkcsv php script.