miniTotoro has asked for the wisdom of the Perl Monks concerning the following question:

My script uses the following code to open an ftp connection:

my $ftp = Net::FTP->new($ftp_addr, Debug => 1) or print "cannot ftp: $@\n";

When I run this on an XP SP2 machine, it works. When I run it on Win2003 x64 I get the following error:

cannot ftp: Net::FTP: connect: Unknown error

They are both using ActivePerl 5.8.8.820 I can use other ftp client applications on the Win2003 machine without any issues.

Anyone have any idea why is this happening and how do I fix it?

Thanks.

Replies are listed 'Best First'.
Re: Net::FTP cannot connect in Windows 2003
by syphilis (Archbishop) on Jul 14, 2007 at 03:30 UTC
    Afaict, the "Unknown error" simply means that a connection with the FTP server at $ftp_addr could not be made. For example I can generate that error by setting $ftp_addr to 127.0.0.1 (there's no ftp server running on this box), or by setting it to 192.168.0.8 (which doesn't exist on my local network).

    Could it be that a firewall that's configured to allow the "other ftp client applications" to work has not been configured to let perl act as an ftp client ?

    Cheers,
    Rob
      Okay, I feel really dumb. Turned out that McAfee was blocking FTP (inbound and outbound). As soon as I disabled that port blocking setting everything worked as advertised. ::sigh:: Thanks for all the help.
      There is no firewall configured on this server. There is only one company firewall, and both the XP and 2003 machines get to the ftp server through that firewall. As I mentioned, the same code was used on both of these machines. The code fails only on the 2003 server.
        I tried $^E and this is what I got:

        cannot connect: An established connection was aborted by the software in your host machine

        Anyone know what this means? I don't off the top of my head. Looks like I will have to do some research. Thanks.
Re: Net::FTP cannot connect in Windows 2003
by Anonymous Monk on Jul 14, 2007 at 03:24 UTC
    Check your firewall, win32 logs...

    "Unknown error" on windows can be anything, use int($!) to see what number it is, then look it up in msdn.

    C:\>perl -le"print $!=$_ for 0 .. 46" Operation not permitted No such file or directory No such process Interrupted function call Input/output error No such device or address Arg list too long Exec format error Bad file descriptor No child processes Resource temporarily unavailable Not enough space Permission denied Bad address Unknown error Resource device File exists Improper link No such device Not a directory Is a directory Invalid argument Too many open files in system Too many open files Inappropriate I/O control operation Unknown error File too large No space left on device Invalid seek Read-only file system Too many links Broken pipe Domain error Result too large Unknown error Resource deadlock avoided Unknown error Filename too long No locks available Function not implemented Directory not empty Illegal byte sequence Unknown error Unknown error Unknown error Unknown error C:\>
      use int($!) to see what number it is, then look it up in msdn

      Seems a good idea. I find (based on non-thorough testing) that int($!) is the same as int($^E), so perhaps simply printing out $^E is all that's needed ?

      Cheers,
      Rob