How do I overcome "Please login with USER and PASS." "Passive mode refused." errors? - when attempting a CPAN module install from within the cpan shell / cpan> prompt
From the output logs to the terminal it appears to be able to connect to an external Perl/CPAN ftp site from my work server but the remote machine is asking for username/password and is rejecting the connection due to my being in passive mode.
( I've tested ftp.perl.org separately and have been able to successfully login with user:anonymous password:anonymous )
So,
- Where do I put the username/password for CPAN program to supply to this remote perl/cpan machine? ( I assume the username is: anonymous, password: anonymous )
- Where do I make a setting to say that I'm in the correct mode (passive/non-passive) such that the remote perl/cpan machine will accept my connection
- Anything else I should do after I have resolved these issues?
Terminal output below, followed by Config.pm in CPAN folder on my server.
My machine is a CentOS Linux machine.
I'm trying to get Date::Calc successfully installed - my ultimate aim. Thanks.
Can't find any answers after a search here and on the internet.
# cpan
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')
cpan> install Date::Calc
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
Warning: Found only 0 objects in /root/.cpan/Metadata
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
LWP failed with code[404] message[File '01mailrc.txt.gz' not found]
Fetching with Net::FTP:
ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
Couldn't fetch 01mailrc.txt.gz from ftp.perl.org
Trying with "/usr/bin/links -source" to get
ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
ELinks: FTP file error
System call "/usr/bin/links -source "ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz" > /root/.cpan/sources/authors/01mailrc.txt"
returned status 1 (wstat 256)
Warning: expected file [/root/.cpan/sources/authors/01mailrc.txt.gz] doesn't exist
Trying with "/usr/bin/wget -O -" to get
ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
--2010-11-08 15:50:51-- ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
=> `-'
Resolving ftp.perl.org... 64.27.65.115, 168.143.19.69
Connecting to ftp.perl.org|64.27.65.115|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/CPAN/authors ... done.
==> SIZE 01mailrc.txt.gz ... 174301
==> PASV ... done. ==> RETR 01mailrc.txt.gz ...
No such file `01mailrc.txt.gz'.
System call "/usr/bin/wget开发者_运维知识库 -O - "ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz" > /root/.cpan/sources/authors/01mailrc.txt"
returned status 1 (wstat 256)
Warning: expected file [/root/.cpan/sources/authors/01mailrc.txt.gz] doesn't exist
Issuing "/usr/bin/ftp -n"
Trying 64.27.65.115...
usage: user username [password] [account]
Local directory now /root/.cpan/sources/authors
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Passive mode refused.
Bad luck... Still failed!
Can't access URL ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz.
Please check, if the URLs I found in your configuration file
(ftp://ftp.perl.org/pub/CPAN/) are valid. The urllist can be edited. E.g.
with 'o conf urllist push ftp://myurl/'
Could not fetch authors/01mailrc.txt.gz
Fetching with LWP:
ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
LWP failed with code[404] message[File '02packages.details.txt.gz' not found]
Fetching with Net::FTP:
ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
Couldn't fetch 02packages.details.txt.gz from ftp.perl.org
Trying with "/usr/bin/links -source" to get
ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
ELinks: FTP file error
System call "/usr/bin/links -source "ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz" > /root/.cpan/sources/modules/02packages.details.txt"
returned status 1 (wstat 256)
Warning: expected file [/root/.cpan/sources/modules/02packages.details.txt.gz] doesn't exist
Trying with "/usr/bin/wget -O -" to get
ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
--2010-11-08 15:51:12-- ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz
=> `-'
Resolving ftp.perl.org... 64.27.65.115, 168.143.19.69
Connecting to ftp.perl.org|64.27.65.115|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/CPAN/modules ... done.
==> SIZE 02packages.details.txt.gz ... 950491
==> PASV ... done. ==> RETR 02packages.details.txt.gz ...
No such file `02packages.details.txt.gz'.
System call "/usr/bin/wget -O - "ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz" > /root/.cpan/sources/modules/02packages.details.txt"
returned status 1 (wstat 256)
Warning: expected file [/root/.cpan/sources/modules/02packages.details.txt.gz] doesn't exist
Issuing "/usr/bin/ftp -n"
Trying 64.27.65.115...
usage: user username [password] [account]
Local directory now /root/.cpan/sources/modules
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Passive mode refused.
Bad luck... Still failed!
Can't access URL ftp://ftp.perl.org/pub/CPAN/modules/02packages.details.txt.gz.
Please check, if the URLs I found in your configuration file
(ftp://ftp.perl.org/pub/CPAN/) are valid. The urllist can be edited. E.g.
with 'o conf urllist push ftp://myurl/'
Could not fetch modules/02packages.details.txt.gz
Fetching with LWP:
ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
LWP failed with code[404] message[File '03modlist.data.gz' not found]
Fetching with Net::FTP:
ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
Couldn't fetch 03modlist.data.gz from ftp.perl.org
Trying with "/usr/bin/links -source" to get
ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
ELinks: FTP file error
System call "/usr/bin/links -source "ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz" > /root/.cpan/sources/modules/03modlist.data"
returned status 1 (wstat 256)
Warning: expected file [/root/.cpan/sources/modules/03modlist.data.gz] doesn't exist
Trying with "/usr/bin/wget -O -" to get
ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
--2010-11-08 15:51:31-- ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz
=> `-'
Resolving ftp.perl.org... 64.27.65.115, 168.143.19.69
Connecting to ftp.perl.org|64.27.65.115|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/CPAN/modules ... done.
==> SIZE 03modlist.data.gz ... 182988
==> PASV ... done. ==> RETR 03modlist.data.gz ...
No such file `03modlist.data.gz'.
System call "/usr/bin/wget -O - "ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz" > /root/.cpan/sources/modules/03modlist.data"
returned status 1 (wstat 256)
Warning: expected file [/root/.cpan/sources/modules/03modlist.data.gz] doesn't exist
Issuing "/usr/bin/ftp -n"
Trying 64.27.65.115...
usage: user username [password] [account]
Local directory now /root/.cpan/sources/modules
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Please login with USER and PASS.
Passive mode refused.
Bad luck... Still failed!
Can't access URL ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz.
Please check, if the URLs I found in your configuration file
(ftp://ftp.perl.org/pub/CPAN/) are valid. The urllist can be edited. E.g.
with 'o conf urllist push ftp://myurl/'
Could not fetch modules/03modlist.data.gz
Going to write /root/.cpan/Metadata
Warning: Cannot install Date::Calc, don't know what it is.
Try the command
i /Date::Calc/
to find objects with matching identifiers.
/usr/lib/perl5/5.8.8/CPAN/Config.pm :-
# This is CPAN.pm's systemwide configuration file. This file provides
# defaults for users, and the values can be changed in a per-user
# configuration file. The user-config file is being looked for as
# ~/.cpan/CPAN/MyConfig.pm.
$CPAN::Config = {
'build_cache' => q[10],
'build_dir' => q[/root/.cpan/build],
'cache_metadata' => q[1],
'cpan_home' => q[/root/.cpan],
'dontload_hash' => { },
'ftp' => q[/usr/bin/ftp],
'ftp_proxy' => q[],
'getcwd' => q[cwd],
'gpg' => q[/usr/bin/gpg],
'gzip' => q[/bin/gzip],
'histfile' => q[/root/.cpan/histfile],
'histsize' => q[100],
'http_proxy' => q[],
'inactivity_timeout' => q[0],
'index_expire' => q[1],
'inhibit_startup_message' => q[0],
'keep_source_where' => q[/root/.cpan/sources],
'links' => q[/usr/bin/links],
'make' => q[/usr/bin/make],
'make_arg' => q[],
'make_install_arg' => q[],
'makepl_arg' => q[],
'ncftp' => q[],
'ncftpget' => q[],
'no_proxy' => q[],
'pager' => q[/usr/bin/less],
'prerequisites_policy' => q[ask],
'scan_cache' => q[atstart],
'shell' => q[/bin/bash],
'tar' => q[/bin/tar],
'term_is_latin' => q[1],
'unzip' => q[/usr/bin/unzip],
'urllist' => [q[ftp://ftp.perl.org/pub/CPAN/]],
'wget' => q[/usr/bin/wget],
};
1;
__END__
Update:
In response to daxim's comment on his answer: "You can edit comments. - Either edit Config.pm, the key urllist is an arrayref of strings; or run o conf urllist at the CPAN prompt. – daxim 16 hours ago" - I tried your suggestions below, daxim:
First I tried:
cpan> o conf urllist
urllist
ftp://ftp.perl.org/pub/CPAN/
Type 'o conf' to view configuration edit options
Followed instructions (i.e. 3rd example bullet under heading "changing of list values: o conf KEY SHIFT|UNSHIFT|PUSH|POP|SPLICE|LIST" at http://search.cpan.org/~andk/CPAN-1.9402/lib/CPAN.pm#changing ) to add a http mirror from: http://www.cpan.org/SITES.html
cpan> o conf urllist http://mirror.ox.ac.uk/sites/www.cpan.org/ ftp://ftp.perl.org/pub/CPAN/
cpan> o conf urllist
urllist
ftp://ftp.perl.org/pub/CPAN/
Type 'o conf' to view configuration edit options
cpan>
So from the above, my HTTP mirror was not added. Can anyone offer some advice?
So then I tried: "Either edit Config.pm, the key urllist is an arrayref of strings; ":
The relevant snippet in Config.pm is:
'urllist' => [q[ftp://ftp.perl.org/pub/CPAN/]],
'wget' => q[/usr/bin/wget],
How would my arrayref look here - with my list of mirrors. i.e. tell me how I should edit it, please.
Update 2:
The instructions given in http://search.cpan.org/~andk/CPAN-1.9402/lib/CPAN.pm#changing (3rd example bullet), to add a URL to the urllist are incomplete, i.e. wrong, they missed out the push. The successful command is:
[root CPAN]# cpan
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')
cpan> o conf urllist push http://mirror.ox.ac.uk/sites/www.cpan.org/
cpan> o conf urllist
urllist
ftp://ftp.perl.org/pub/CPAN/
http://mirror.ox.ac.uk/sites/www.cpan.org/
Type 'o conf' to view configuration edit options
cpan>
From:
http://www.perlmonks.org/?node_id=551175
Other important things:
Beforehand, must check if installing a new module, whether or not it also installs dependencies - i.e other modules - and if they are newer versions of those existing on the machine and therefore if their behaviour or interface has changed that would impact existing applications running on the machine: Does CPAN installing of new modules impact Perl-CGI applications on same live production server?
Update 3:
It would appear that editing the urllist is not persistent, as, on re-entering cpan after previous exit, only the ftp entry remains.
cpan> o conf urllist
urllist
ftp://ftp.perl.org/pub/CPAN/
Type 'o conf' to view configuration edit options
Overcome FTP problems (it's a really stupid network protocol) by selecting a HTTP mirror.
I'm not sure why you are getting the username/password prompt, but I believe that you should be able to set it to the values you specified above by creating a ~/.netrc
file that looks something like this
machine ftp.perl.org
login anonymous
password anonymous@cpan.org
or you can force all ftp requests to be automatically anonymous unless specified otherwise by putting this line in ~/.netrc
default login anonymous password anonymous@cpan.org
Every FTP client and library I have ever used honors the .netrc
file. It is one way to keep the password for a site out of your source code, even if it is sitting in plain text.
I think you're misdiagnosing the problem -- you're encountering errors much sooner, e.g. in the lines
Fetching with LWP:
ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
LWP failed with code[404] message[File '01mailrc.txt.gz' not found]
Do you have a proxy or a firewall set up between this machine and the internet? This connection is failing.
精彩评论