Re: [Bug-wget] Any explanation for the '-nc' returned value?
Forgot to say, I use this in scripts to update some software. There is already the 'old' file existing. If the first try fails, I certainly should do as you say. If it returns failed for 'preventing do anything when local file exists', it is weird. That is what we want. I mean it should return succeed. It worked as we specified: don't overwrite nor download in to a new file. (RCE?) I am not going to change the behavior of '-nc', but just confused with the return value. Thanks for your reply and patience Tim! I can just change it in my own compilation :p Best Regards, YX Hao -Original Message- From: Tim Rühsen To: Yuxi Hao; 'Dale R. Worley' Cc: bug-wget@gnu.org Subject: Re: [Bug-wget] Any explanation for the '-nc' returned value? On 30.07.2018 16:44, Yuxi Hao wrote: > Let's take an example in practice. > When there is a bad network connection, I try wget with '-nc' directly first, > if it fails, then I'll try it with proxy. If it says "File * already there ; > not retrieving.", and returns 1 as described (error occurred, failed), that > is so weird! After the first try failed, you should explicitly move/remove the file out of the way. That is not weird, it's a safety feature. It might save you when having a typo or when an URL is retrieved that you itself can't trust. You could easily overwrite files in your home directory, e.g. .profile or .bashrc. That is easily used as an Remote Code Execution (RCE). So no way we "fix" this ;-)
Re: [Bug-wget] Any explanation for the '-nc' returned value?
On 30.07.2018 16:44, Yuxi Hao wrote: > Let's take an example in practice. > When there is a bad network connection, I try wget with '-nc' directly first, > if it fails, then I'll try it with proxy. If it says "File * already there ; > not retrieving.", and returns 1 as described (error occurred, failed), that > is so weird! After the first try failed, you should explicitly move/remove the file out of the way. That is not weird, it's a safety feature. It might save you when having a typo or when an URL is retrieved that you itself can't trust. You could easily overwrite files in your home directory, e.g. .profile or .bashrc. That is easily used as an Remote Code Execution (RCE). So no way we "fix" this ;-) > And '-N' is not always working as desired, because of "Last-modified header > missing". One example: > wget -N > https://www.gnu.org/software/wget/manual/html_node/Download-Options.html If the server doesn't support it, it simply won't work. All you can do is not to use -N or ask the server's admin to support it. Regards, Tim > > Best Regards, > YX Hao > > -Original Message- > From: Dale R. Worley > To: Tim Rühsen > Cc: lifenjoine; bug-wget > Subject: Re: [Bug-wget] Any explanation for the '-nc' returned value? > > Tim Rühsen writes: >>-nd, even if -r or -p are in effect.) When -nc is >> specified, this behavior is suppressed, and Wget will >>refuse to download newer copies of file. > > Though strictly speaking, this doesn't say that wget will then exit with > error code 1. > > Dale > > signature.asc Description: OpenPGP digital signature
Re: [Bug-wget] Any explanation for the '-nc' returned value?
Let's take an example in practice. When there is a bad network connection, I try wget with '-nc' directly first, if it fails, then I'll try it with proxy. If it says "File * already there ; not retrieving.", and returns 1 as described (error occurred, failed), that is so weird! And '-N' is not always working as desired, because of "Last-modified header missing". One example: wget -N https://www.gnu.org/software/wget/manual/html_node/Download-Options.html Best Regards, YX Hao -Original Message- From: Dale R. Worley To: Tim Rühsen Cc: lifenjoine; bug-wget Subject: Re: [Bug-wget] Any explanation for the '-nc' returned value? Tim Rühsen writes: >-nd, even if -r or -p are in effect.) When -nc is > specified, this behavior is suppressed, and Wget will >refuse to download newer copies of file. Though strictly speaking, this doesn't say that wget will then exit with error code 1. Dale
Re: [Bug-wget] Any explanation for the '-nc' returned value?
Tim Rühsen writes: >-nd, even if -r or -p are in effect.) When -nc is specified, > this behavior is suppressed, and Wget will >refuse to download newer copies of file. Though strictly speaking, this doesn't say that wget will then exit with error code 1. Dale
Re: [Bug-wget] Any explanation for the '-nc' returned value?
Hi, from the man pages (--no-clobber): When running Wget without -N, -nc, -r, or -p, downloading the same file in the same directory will result in the original copy of file being preserved and the second copy being named file.1. If that file is downloaded yet again, the third copy will be named file.2, and so on. (This is also the behavior with -nd, even if -r or -p are in effect.) When -nc is specified, this behavior is suppressed, and Wget will refuse to download newer copies of file. Therefore, ""no-clobber"" is actually a misnomer in this mode---it's not clobbering that's prevented (as the numeric suffixes were already preventing clobbering), but rather the multiple version saving that's prevented. Regards, Tim On 28.07.2018 15:52, Yuxi Hao wrote: > Hi Guys, > > > > The source code is: > > > > if (opt.noclobber && file_exists_p(opt.output_document, NULL)) > >{ > > /* Check if output file exists; if it does, exit. */ > > logprintf (LOG_VERBOSE, > > _("File %s already there; not retrieving.\n"), > > quote (opt.output_document)); > > exit (WGET_EXIT_GENERIC_ERROR); > >} > > > > > > No explanation on it: > > https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html > > > > I am confused on this. If it works as specified, why don’t we return succeed? > > > > Best Regards, > > YX Hao > > > signature.asc Description: OpenPGP digital signature