Net::FTP problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

The following code is generating the error: can't connect (in the code
below) I'm guessing the FTP is sending the username and hostname
separated by @ instead of sending just the host name followed by user
name and password and commands. It worked fine for some time but now
quit on me. Thanks for any of your help.

sub get_ftp_handle {
  my($self, $ftp_host, $ftp_user, $ftp_pwd)=@_;

  my $ftp_site = $ftp_host || "storm";
  my $ftp_pass = $ftp_pwd || "pqww2o4";
  $ftp_user ||=  "qauser";

  my $ftp = Net::FTP->new($ftp_site) || do {
     warn "$ftp_user\@$ftp_site: can't connect\n";
     return -1;
  $ftp->login($ftp_user, $ftp_pass) || warn "$ftp_user\@$ftp_site:
can't login\n";
  return $ftp || die("cannot open ftp connection");

Re: Net::FTP problem wrote:
Quoted text here. Click to load it

No. The error message is misleading. The routine attempts to make a
connexion to the $ftp_host. This fails.

Quoted text here. Click to load it

This is a major clue that this function is not at fault but that
something external has changed.

Perhaps the values that are being handed to the function mean that
$ftp_host receives a invalid value which in turn sets $host_site to be

Or maybe there have been system or network changes so that the host
is no longer reachable either through the network or by whatever name is
being used - perhaps someone removed "storm" from the /etc/aliases file
- just a wild guess.

The best thing is to try a direct FTP session from the command line to
the host and see if a connexion can be made.
Quoted text here. Click to load it

Should be:

      warn "$ftp_site: can't connect\n";

Quoted text here. Click to load it


Re: Net::FTP problem wrote:
Quoted text here. Click to load it

Net::FTP will never send user:pass@host, because this is
just a way some clients allow the data to be entered.
However, your code doesn't even reach the login line.

Quoted text here. Click to load it

So something must have been changed. Did you alter your
script in some other parts? If no, has the server been
altered (ip changed, ftp daemon stopped)? Has someone
changed the firewall you are behind (if there is one)?
Does your

Quoted text here. Click to load it

 From the perldoc of Net::FTP's constructor:
If the constructor fails undef will be returned and an error
message will be in $@.

So make the code above
   my $ftp = Net::FTP->new($ftp_site) or do {
     warn "Unable to connect to $ftp_site. Error is: $@\n";
     return -1;
to find out why the connection failed.


Re: Net::FTP problem

Thanks for trying to help me out. The  $@  is empty. The connection is
successful but the login is reporting an error. There is no problem
with manually trying to connect to the host. The fact is this code
worked perfectly fine for some time. And it is broke all of a sudden.
Our system administrators are  unable to help me because they don't
know perl.

Re: Net::FTP problem

The problem got resolved by resetting the passwords. Thanks for your

Site Timeline