Have you tried manually connecting via FTP? perhaps theres an intermediate problem. Raising the debugging level might also help realizing where the problem lies. If you type 'netstat' in the command line whilst the script hangs you may also see the connection listed, and what state it is in.