Disturbed Posted August 29, 2008 Share Posted August 29, 2008 In shell you can do wget and hence we can use system to execute it from linux. Now curl offers similar functionality and from the looks of it, it has more options. Which is better to use? My only preference is that I do not want the php page calling those to wait for them to get the file. That is I would like them to run in the background. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/121822-downloading-files-using-curl-or-using-system/ Share on other sites More sharing options...
JonnoTheDev Posted August 29, 2008 Share Posted August 29, 2008 Its not really a case of which is better to use, it is a case of what do you want to do with each. WGET is fine for grabbing webpages and storing as static files, even grabbing images but not so great if lets say you wanted to spider a website checking all the links work, etc. Quote Link to comment https://forums.phpfreaks.com/topic/121822-downloading-files-using-curl-or-using-system/#findComment-628570 Share on other sites More sharing options...
Disturbed Posted August 29, 2008 Author Share Posted August 29, 2008 Its not really a case of which is better to use, it is a case of what do you want to do with each. WGET is fine for grabbing webpages and storing as static files, even grabbing images but not so great if lets say you wanted to spider a website checking all the links work, etc. My task is simple just download a file and look like a regular pc is downloading it. So far curl has done well. My only requirement is to have the php script run in the background versus requesting it and waiting for it to get the file as the file might be 100+MB. Quote Link to comment https://forums.phpfreaks.com/topic/121822-downloading-files-using-curl-or-using-system/#findComment-628574 Share on other sites More sharing options...
JonnoTheDev Posted August 29, 2008 Share Posted August 29, 2008 Then it needs to be run as a shell script. You could setup a cron to run it. Quote Link to comment https://forums.phpfreaks.com/topic/121822-downloading-files-using-curl-or-using-system/#findComment-628577 Share on other sites More sharing options...
Disturbed Posted August 29, 2008 Author Share Posted August 29, 2008 Then it needs to be run as a shell script. You could setup a cron to run it. Ok I am running it on curl now, so that cant be changed? By shell script you mean write a shell script and call using system in php right?. and the shell script would look like wget ... & ? Quote Link to comment https://forums.phpfreaks.com/topic/121822-downloading-files-using-curl-or-using-system/#findComment-628747 Share on other sites More sharing options...
DarkWater Posted August 29, 2008 Share Posted August 29, 2008 Did you just try something like: `wget -nd something.com > /dev/null` Read this note on exec() from the PHP manual: Note: If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends. Quote Link to comment https://forums.phpfreaks.com/topic/121822-downloading-files-using-curl-or-using-system/#findComment-628755 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.