wget hangs with -r and -O -

佐手、 提交于 2019-12-06 03:52:58

Of course:

 wget -r -O file www.blankwebsite.com

works, but the BUG is that:

 wget -r -O - www.blankwebsite.com

hangs!

The same problem is if you create a FIFO

mkfifo /tmp/myfifo
wget -r -O /tmp/myfifo www.blankwebsite.com

wget, when called with -r option, will try to find HTML "a href=..." tags reading the output file. Since the output file is a FIFO or stdout (ex. HYPHEN char '-') it is not able to find any tag and waits for INPUT. Then you will have a wget process waintg forever on a read system call.

To resolve this you can: 1) Patch wget to handle this case 2) Patch wget to not allow "-r -O -" combination... (Just check that the argument of '-O' is a regular file) 3) Use a workaround like:

TMPFILE=$(mktemp /tmp/wget.XXXXXX)
wget -r -O $TMPFILE www.blankwebsite.com
grep STRING $TMPFILE
rm $TMPFILE

@tonjo : Can you please try using the following code.

wget -r -O file www.blankwebsite.com

instead of using

 wget -r -O - www.blankwebsite.com

as stated in the documentation:

 Similarly, using '-r' or '-p' with '-O' may not work as you expect:
 Wget won't just download the first file to FILE and then download
 the rest to their normal names: _all_ downloaded content will be
 placed in FILE.  This was disabled in version 1.11, but has been
 reinstated (with a warning) in 1.11.2, as there are some cases
 where this behavior can actually have some use.

That is a known problem, that is also downloaded somehow, using -r and -O with non seekable files doesn't work with the way wget serialize the data directly to the file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!