in reply to Net::Ftp->login problem

Are you testing / displaying the error-codes returned?

Failing that, have you tried manually performing the steps your program would take?

You might also consider showing us the relevant code. It's possible you have a phase-of-the-moon problem that only occurs the Nth time a piece of code gets executed.

Replies are listed 'Best First'.
Re^2: Net::Ftp->login problem
by KianTern (Acolyte) on Oct 31, 2007 at 10:13 UTC
    I do have permission those ftp accounts where created for my usage. Firewall not blocking i can access the sites with standard ftp client all the access info was copy/pasted from the origial documents. I also tried to copy paste the user and pass from my .pwd file and it works great and I still can connect to one remote and one local ftps using this code
    #!/usr/bin/perl -w use Net::FTP; use strict; my $site = shift @ARGV; my $dir = shift @ARGV; my $sd = "/SCRIPTS"; my $wd = "/DATA"; my $access_file="$sd/ftp_access_info/$site.pwd"; my $ftp; # name for the ftp class my $host; # ftp name my $user; # user name for ftp my $pass; # password for ftp my @files; # list of files on the ftp #get access info from file open(FTP_ACCESS, "<" , $access_file); my @ftp_access = <FTP_ACCESS>; chomp @ftp_access; close (FTP_ACCESS); #set access info $host = $ftp_access[0]; $user = $ftp_access[1]; $pass = $ftp_access[2]; print "|$host|\n|$user|\n|$pass|\n"; #get directory listing print "Connecting\n"; $ftp=Net::FTP->new("$host",Timeout=>240) or die "connect\n"; print "Loging in\n"; $ftp->login("$user","$pass") or die "login\n"; print "Getting File lists\n"; $ftp->cwd($dir) if $dir; @files=$ftp->dir or die "dir\n"; print "$_\n" foreach @files; $ftp->quit;
      I am a little bit confused by something, perhaps I am not understanding you correctly, just to clear things up let me ask a question that may sound silly. Do you expect the code above to login to one ftp server after another, and perform the same operation? If this is the case then you will need to look at some sort of loop (a for loop say) so that the process is repeated for each .pwd file you have in a folder.
        It's a part of larger script system that will launch this script with needed parameters. The scripts also do some manipulations with the received files different for each ftp and I want to be able to disable any site in case I need to.
      Try setting the ftp to PASSIVE mode after connecting. You can set it during the connection initiation string if you would like by using it as an %option (read the Net::FTP documentation for specifics).

      $ftp->pasv;

      Here is a reasonable explanation of the difference between Active and Passive ftp and what is happening that might require a PASV connection.



      "The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it." - Terry Pratchett
      Firewalls are known to block programs