'wget' perform redirects by default and that's why always succeeds. If your link points to real file, redirect is performed to the pointed file. When some link is invalid, error message gets back immediately. That's why you are getting "200 OK" for both valid and invalid link (the error message is valid □). It's not so trivial cosa Dropbox links are dynamically generated and even when no real file exists link point to error message (as a content, it's still valid). You want to check not for error in transfer process or error because of existing (already) file, but link validity. Now (after explicit destination pointing) a try downloading already existing file (probably downloaded before) will result in general error (exit status 1, no more 0), which you can check. Where 'filename.ext' is the desirable file name (possibly path prepended). To force existing file consideration as an error, you can use something like: wget -nc -O filename.ext dropbox_url Keep in mind that in such a case existing file is NOT considered error! That's why you're getting success and probably got confused. No, no another file will get downloaded, while 'dropbox_url' keeps the same. File not found (HTTP status 404) gets transformed to server issued an error response - exit status 8, for -nc dropbox_url Any different exit status means that something happens considered as a error. For most commands (including 'wget'), success is denoted by zero. Hi any kind of error that might come up on command line, you can check the retrieved result.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |