如何检查“lwp-download”是否正常工作?
我对Perl一无所知,但我迫切需要修改一个Perl脚本。在某个时刻,它使用 system("lwp-download $HttpPath $Out");
从服务器下载大约 500MB 的文件。
有什么方法可以确定下载过程是否正确,例如检查下载的文件是否与原始文件大小相同?
谢谢
I don't know anything about Perl but I urgently need to modify a Perl script. At some point it's downloading an about 500MB file from a server using system("lwp-download $HttpPath $Out");
.
Is there any way I can find out if the downloading process went correctly, e.g. check whether downloaded file has the same size as the original one?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,
system
命令返回* 正在运行的程序的退出状态。按照惯例,返回值为零意味着成功,非零意味着某种错误。典型的习惯用法类似于
* - 有点像
perldoc -f system
了解详细信息In general, the
system
command returns* the exit status of the program that it was running. By convention a return value of zero means success, and non-zero means some sort of error.A typical idiom is something like
* - sort of, see
perldoc -f system
for details从 Perl 程序中取出来运行另一个 Perl 程序 lwp-download 是一件愚蠢的事情。只需用
LWP::Simple
mirror
API 替换该调用即可code> 并且您可以直接在程序中获得不错的错误报告,而不是弄乱退出代码。如果您需要更好/更细粒度的错误检查,请使用
LWP 的
也可用。mirror
::UserAgentIt's a dumb thing to shell out from your Perl program to run
lwp-download
, another Perl program. Just replace that call with themirror
API fromLWP::Simple
and you get decent error reporting, directly there in your program instead of messing with exit codes.Should you need even better/fine-grained error checking,
mirror
fromLWP::UserAgent
is available, too.