Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Net::Ftp->login problem

by KianTern (Acolyte)
on Oct 31, 2007 at 10:13 UTC ( [id://648211]=note: print w/replies, xml ) Need Help??


in reply to Re: Net::Ftp->login problem
in thread Net::Ftp->login problem

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;

Replies are listed 'Best First'.
Re^3: Net::Ftp->login problem
by marto (Cardinal) on Oct 31, 2007 at 10:35 UTC
    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.
        What do the log files on the other ftp servers (that don't work) say? Do they even show a login attempt? Is it always one particular ftp server that works when you hard code its details? Do you get any error messages on screen when you run your script?
Re^3: Net::Ftp->login problem
by Rabbi Bob (Scribe) on Nov 01, 2007 at 10:43 UTC
    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
Re^3: Net::Ftp->login problem
by Anonymous Monk on Oct 31, 2007 at 10:20 UTC
    Firewalls are known to block programs

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://648211]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-16 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found