1

我可以在 Linux 命令行上使用 wget 命令从另一台服务器下载文件,例如:

wget ftp_site_name/file_name

但是当我在 perl 脚本中运行 wget 时,我无法下载相同的文件

system "/usr/bin/wget ftp_site_name/file_name";

或者

system "wget ftp_site_name";

以下是错误消息的片段:

Resolving ftp site  ...xx.xx.x.xx

Connecting to ftp site|xx.xx.x.xx|:xx... connected.

Logging in as anonymous ... Logged in!

==> SYST ... done.    ==> PWD ... done.

==> TYPE I ... done.  ==> CWD (1) /pub/??/??/ ...

No such directory `pub/??/??/'.

有什么建议么?

4

1 回答 1

0

如果没有实际的错误消息,很难判断出了什么问题,但我有一些猜测:

如果路径包含通配符或空格,请使用撇号或转义。

my $ftpname="/pub/some path with spaces/works_with_wildchar?/";
my $out = `wget '$ftpname'`;
print "out:\n$out\n";

or
my $ftpname="/pub/some path with spaces/works_with_wildchar?/";
my $out = qx!wget $ftpname!;
print "out:\n$out\n";
于 2012-11-09T15:55:47.203 回答