如何强制wget输出摘要?


2

我有一个bash脚本,它启动一系列wget命令并记录输出。我使用以下选项:

wget --no-verbose --page-requisites --adjust-extension --convert-links --backup-converted --timestamping --wait=1 --random-wait --append-output="$logfile" --recursive --level=2 http://example.com

日志应以:

Terminé  2014-10-09 18:06:40 
Temps total effectif : 1m 7s
Téléchargé: 11 fichiers, 79K en 0,06s (1,22 MB/s)

但有时候没有这样的总结,我看到的只是发生的错误:

http://example.com/robots.txt:
2014-10-09 18:06:41 erreur 404 : Ce fichier n'existe pas (404).
http://example.com/index.html:
2014-10-09 18:08:27 erreur 404 : Ce fichier n'existe pas (404).
http://example.com/folder1/folder2/default.asp.html:
2014-10-09 18:08:31 erreur 404 : Ce fichier n'existe pas (404).
http://example.com/folder1/index.html:
2014-10-09 18:08:56 erreur 404 : Ce fichier n'existe pas (404).
http://example.com/folder1/folder2/folder3/"../images/bullet.gif":
2014-10-09 18:09:28 erreur 403 : Action interdite.

为什么不显示摘要?是因为没有下载新文件,还是因为出现了很多服务器错误(404,403)?


如果所有你看到的是发生了错误,那么我想这意味着WGET无法获取任何东西。如果没有下载任何内容,最后您将看不到统计信息。
Vinayak 2014年

Answers:


3

是因为没有下载新文件,[...]?

是。而已。如果已下载零字节,则不会有摘要。这是因为下面的if语句的后半部分:“total_downloaded_bytes!= 0”

来自wget Git回购的来源:

if ((opt.recursive || opt.page_requisites
       || nurl > 1
       || (opt.input_filename && total_downloaded_bytes != 0))
      &&
      total_downloaded_bytes != 0)

如何强制wget输出摘要?

似乎没有选择强迫这一点。我可以想到这些替代方案:

  • 从源中删除两行并重新编译您自己的私有构建。
  • wget bug跟踪器提交显式选项的功能请求。
  • 每次下载1字节的虚拟文件。这应该强制显示摘要。

是否可以在与当前递归下载相同的命令中下载虚拟文件?
Manu

我在日志的最后一行添加了一个简单的“tail | grep”; 然后我显示最后3行,如果文件已被下载,否则我回显消息“没有下载新文件”。
Manu
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.