StormTheGates Posted December 21, 2011 Share Posted December 21, 2011 Hey all, having a very odd problem this morning. I have a cron job that executes a script that performs the following action: "lynx --dump "php page"" This executes fine, I see all the output. The problem is this: The php file is supposed to write information to a file. When executed by a user on a web browser like Chrome or Firefox, the data is written to the file with no problem. However with lynx the file is created with size 0, and no data is ever written. Any ideas why this may be? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/253615-lynx-php-write-error/ Share on other sites More sharing options...
premiso Posted December 21, 2011 Share Posted December 21, 2011 Hard to say without the actual cronjob setup or any code. If the cron is something like: lynx --dump "http://yoursite.com/phppage.php" It should work, if it is not preceded with the http, that would be a problem. The other potential issue, is if the site is using session / cookies, lynx may be asking for permission for those cookies. You may be better off with wget or curl for the processing in that case. Quote Link to comment https://forums.phpfreaks.com/topic/253615-lynx-php-write-error/#findComment-1300152 Share on other sites More sharing options...
StormTheGates Posted December 21, 2011 Author Share Posted December 21, 2011 How can I get the page to be processed without lynx? Lynx was asking for permissions earlier for cookies, I told it to always accept. The code is a very simple: $ourFileName = "export.csv"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fwrite($ourFileHandle, "all data"); fclose($ourFileHandle); Cronjob setup is: 45 9 * * * lynx "site" > /opt/websites/wut.log But Ive also tried using a visit.sh shell script that did the following: lynx --dump "site" Same result from both. Quote Link to comment https://forums.phpfreaks.com/topic/253615-lynx-php-write-error/#findComment-1300159 Share on other sites More sharing options...
premiso Posted December 21, 2011 Share Posted December 21, 2011 Use curl, if it is installed: 45 9 * * * /usr/bin/curl --silent --compressed curl http://site.com/cron.php > /dev/null >2 &1 Or wget if it is installed: 45 9 * * * /usr/bin/wget -q http://site.com/cron.php > /dev/null >2 &1 Quote Link to comment https://forums.phpfreaks.com/topic/253615-lynx-php-write-error/#findComment-1300181 Share on other sites More sharing options...
StormTheGates Posted December 22, 2011 Author Share Posted December 22, 2011 Curl worked wonders, thank you! Quote Link to comment https://forums.phpfreaks.com/topic/253615-lynx-php-write-error/#findComment-1300542 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.