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

$ftp=Net::FTP->new($host,Timeout=>240) or die "connect\n"; print "Created new FTP method\n" ; $ftp->login("xxx","yyy") or die "cannot login\n";

It fails after print statement, The ouptput i got is
Net::FTP>>> Net::FTP(2.72) Net::FTP>>> Exporter(5.58) Net::FTP>>> Net::Cmd(2.24) Net::FTP>>> IO::Socket::INET(1.27) Net::FTP>>> IO::Socket(1.28) Net::FTP>>> IO::Handle(1.24) Net::FTP=GLOB(0x1a04110)<<< 220 FTP server (Hummingbird Ltd. (HCLFTPD +) Version 10.0.0.0) ready. Created new FTP Net::FTP=GLOB(0x1a04110)>>> user GGGG Net::FTP=GLOB(0x1a04110)<<< 331 Password required for GGGG. Net::FTP=GLOB(0x1a04110)>>> PASS .... Net::FTP=GLOB(0x1a04110)<<< 530 User GGGG: can't change directory to \ +\DATA\ GGGG $. Cannot login
when i ftp through DOS prompt it gave me
ftp> open To a.aaa.aaa.aaa Connected to a.aaa.aaa.aaa. 220 FTP server (Hummingbird Ltd. (HCLFTPD) Version 10.0.0.0) ready. User (a.aaa.aaa.aaa:(none)): username 331 Password required for ggggg. Password: 530 User ggggg: can't change directory to \\gggg\ddddd. Login failed.

Replies are listed 'Best First'.
Re: FTP error
by leighsharpe (Monk) on Dec 31, 2007 at 06:08 UTC
    Looks like an error on the FTP server to me.
    Your DOS login fails. Therefore it is reasonable to expect that a login from your perl script will also fail.
    The 530 error message indicates that the server can't chroot you to the directory it beleives to be your home directory. Make sure it exists and you have sufficient access to it.
    Only when you are able to log in from a DOS FTP will you have any hope of getting in from your perl script.
Re: FTP error
by GrandFather (Saint) on Dec 31, 2007 at 06:05 UTC

    What error message do you get if you:

    $ftp->login("xxx","yyy") or die "cannot login: ", $ftp->message;

    Perl is environmentally friendly - it saves trees
      Error i got is
      Net::FTP>>> Net::FTP(2.72) Net::FTP>>> Exporter(5.58) Net::FTP>>> Net::Cmd(2.24) Net::FTP>>> IO::Socket::INET(1.27) Net::FTP>>> IO::Socket(1.28) Net::FTP>>> IO::Handle(1.24) Net::FTP=GLOB(0x1a04110)<<< 220 FTP server (Hummingbird Ltd. (HCLFTPD +) Version 10.0.0.0) ready. Created new FTP Net::FTP=GLOB(0x1a04110)>>> user GGGG Net::FTP=GLOB(0x1a04110)<<< 331 Password required for GGGG. Net::FTP=GLOB(0x1a04110)>>> PASS .... Net::FTP=GLOB(0x1a04110)<<< 530 User GGGG: can't change directory to \ +\DATA\ GGGG $. Cannot login

        So, the same result as you got doing it manually. Not a Perl related problem then. You need to sort out the FTP problem, which looks like an invalid user problem, before you can get the Perl end of things working.


        Perl is environmentally friendly - it saves trees
Re: FTP error
by nimdokk (Vicar) on Dec 31, 2007 at 14:59 UTC
    In looking at the messages, I would suggest talking with the FTP server admin. It could be a problem where the user does not have the appropriate permission to the home directory. Have the admin check to make sure your user is a member of the correct groups to have access to the user home directory. Sounds silly, but I've seen it happen.
      Thanks all! that folder actually does not exit and thats why it gave me error as it was tring to chabge directory.