报错信息如下
[root@localhost ~]# cpan IPC::Cmd
Fetching with HTTP::Tiny:
http://www.cpan.org/authors/01mailrc.txt.gz
HTTP::Tiny failed with an internal error: Could not read from socket: 'Connection reset by peer'
Trying with
/usr/bin/curl -L -f -s -S --netrc-optional
to get
http://www.cpan.org/authors/01mailrc.txt.gz
curl: (56) Recv failure: Connection reset by peer
Function system("/usr/bin/curl -L -f -s -S --netrc-optional "http://www.cpan.org/authors/01mailrc.txt.gz" > "/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570"")
returned status 56 (wstat 14336), left
/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570 with size 0
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570'. Giving up on it.
Trying with
/usr/bin/curl -L -f -s -S --netrc-optional
to get
http://www.cpan.org/authors/01mailrc.txt.gz
curl: (56) Recv failure: Connection reset by peer
Function system("/usr/bin/curl -L -f -s -S --netrc-optional "http://www.cpan.org/authors/01mailrc.txt.gz" > "/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570"")
returned status 56 (wstat 14336), left
/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570 with size 0
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570'. Giving up on it.
No external ftp command available
Fetching with HTTP::Tiny:
http://www.cpan.org/authors/01mailrc.txt.gz
HTTP::Tiny failed with an internal error: Could not read from socket: 'Connection reset by peer'
Trying with
/usr/bin/curl -L -f -s -S --netrc-optional
to get
http://www.cpan.org/authors/01mailrc.txt.gz
curl: (56) Recv failure: Connection reset by peer
Function system("/usr/bin/curl -L -f -s -S --netrc-optional "http://www.cpan.org/authors/01mailrc.txt.gz" > "/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570"")
returned status 56 (wstat 14336), left
/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570 with size 0
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570'. Giving up on it.
Trying with
/usr/bin/curl -L -f -s -S --netrc-optional
to get
http://www.cpan.org/authors/01mailrc.txt.gz
curl: (56) Recv failure: Connection reset by peer
Function system("/usr/bin/curl -L -f -s -S --netrc-optional "http://www.cpan.org/authors/01mailrc.txt.gz" > "/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570"")
returned status 56 (wstat 14336), left
/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570 with size 0
Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp24570'. Giving up on it.
No external ftp command available
Please check, if the URLs I found in your configuration file
(http://www.cpan.org/) are valid. The urllist can be edited. E.g. with 'o
conf urllist push ftp://myurl/'
Could not fetch authors/01mailrc.txt.gz
**cpan IPC::Cmd 执行该命令报错尝试解决办法**
**更改CPAN镜像:** 有时候默认的CPAN镜像可能宕机或有问题。你可以更换为另一个镜像。编辑CPAN配置并更新`urllist`。
进入CPAN shell:
cpan
o conf urllist
o conf urllist shift http://www.cpan.org/
o conf urllist unshift http://mirror.cpan.org/
o conf commit
**手动更新CPAN配置:** 你可以手动编辑CPAN配置文件,通常位于`~/.cpan/CPAN/MyConfig.pm`或root用户的`/root/.cpan/CPAN/MyConfig.pm`。添加或更新`urllist`设置:
```
'urllist' => [
'http://mirror.cpan.org/',
'http://www.cpan.org/',
],
```
**使用不同的CPAN安装工具:** 尝试使用`cpanm`(CPAN Minus),这是一个更轻量且用户友好的工具来安装Perl模块。
首先安装`cpanm`:
```sh
curl -L https://cpanmin.us | perl - --sudo App::cpanminus
```
然后使用`cpanm`安装所需的模块:
```sh
cpanm IPC::Cmd
```
后续升级可以参考我发的脚本