从命令行wget

时间:2012-11-09 14:42:59

标签: perl wget

我可以在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/??/??/'.

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

如果没有实际的错误信息,很难说出错了,但我有一些猜测:

如果路径包含wild chars或空格,则使用撇号或转义。

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";