I’m running wget through php’s shell_exec()
How could I understand that wget got 404 error getting file?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to this, when faced with a simple “download file XYZ” operation, wget will return a return code of 1 when the download fails for some reason. It won’t work for complex operations like mirroring a site, but in your case, it should be fine.
You can get hold of the return code using exec()`s “return_var” variable.
Wget should return
1(or some other status code that is not0) if it is presented with a proper 404 page. Try it out.To actually distinguish the exact error status code that wget receives, I think you’ll have to start parsing its output (or use a PHP-based web client class.)