Re: Net::Ftp->login problem
by marto (Cardinal) on Oct 31, 2007 at 09:47 UTC
|
If, as you cliam this works command line then there is something wrong with your code. Do check that each operation is successful, and if not display (or otherwise alert you) to the fact an error has occured? If you post your code (remove sensitive data, passwords etc) someone will try and help you. Please read How do I post a question effectively? and the PerlMonks FAQ if you have not already done so.
Martin | [reply] |
Re: Net::Ftp->login problem
by syphilis (Archbishop) on Oct 31, 2007 at 09:51 UTC
|
Might help if you provide the Debug => 1 argument to the new() constructor.
Do the ftp connections that fail also fail from a script that attempts to make just the *one* connection (to that ftp site) ?
Some code might help - just a simple demo (with names and passwords changed, of course).
Cheers, Rob | [reply] [d/l] |
Re: Net::Ftp->login problem
by apl (Monsignor) on Oct 31, 2007 at 09:53 UTC
|
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. | [reply] |
|
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;
| [reply] [d/l] |
|
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.
| [reply] |
|
|
|
| [reply] [d/l] |
|
Firewalls are known to block programs
| [reply] |
Re: Net::Ftp->login problem
by nimdokk (Vicar) on Oct 31, 2007 at 12:07 UTC
|
I'm going to reiterate the comment someone else made: enable the debug mode. It can be very helpful with figuring out what is wrong. To enable debug mode, simply use the following line:
$ftp=Net::FTP->new("$host",Timeout=>240,Debug=>1) or die "connect\n";
Also, I would recommend looking at the logs from the server you are attempting to connect to. If you do not have access to these logs, kindly ask your friendly neighborhood sysadmin to help you out.
| [reply] [d/l] |
|
Thank you all but I guess problem was not from my side
now everything (almost) works as it should
| [reply] |
Re: Net::Ftp->login problem
by narainhere (Monk) on Oct 31, 2007 at 11:30 UTC
|
| [reply] |
Re: Net::Ftp->login problem
by Anonymous Monk on Oct 31, 2007 at 09:50 UTC
|
1. you are hardcode incorrectly
2. you are reading incorrectly
3. you don't have permission (firewall...)
| [reply] |