sureshp Posted December 11, 2007 Share Posted December 11, 2007 Hi all, I have to run a spider script for a website whenever needed by just clicking a link "Index the site" in the admin panel. For this, I need to run the command "php spider.php -u http://www.domainname.com -r" in a php script. I tried it via system() and exec() functions, but no luck. Can anyone help me in this regard to figure out a way to achieve this? Thanks, Suresh P Quote Link to comment Share on other sites More sharing options...
sureshp Posted December 11, 2007 Author Share Posted December 11, 2007 Can anyone having idea on this? Thanks, Suresh P Quote Link to comment Share on other sites More sharing options...
trq Posted December 11, 2007 Share Posted December 11, 2007 I tried it via system() and exec() functions, but no luck. Whatr exactly do you mean by no luck? What happend? Quote Link to comment Share on other sites More sharing options...
sureshp Posted December 12, 2007 Author Share Posted December 12, 2007 I meant that i tried to execute the above command via system() and exec(). But, its not working for me. If I run the same command thru commandline, its working and the website is indexed. Is there anything related to settings? Thanks! Quote Link to comment Share on other sites More sharing options...
shaymol Posted December 12, 2007 Share Posted December 12, 2007 Hi You can try with back-tick(`) or shell_exec(). Ex: `php spider.php -u http://www.domainname.com -r`; or shell_exec("php spider.php -u http://www.domainname.com -r"); Quote Link to comment Share on other sites More sharing options...
sureshp Posted December 12, 2007 Author Share Posted December 12, 2007 Thanks for your response. I tried the way you had mentioned here. But, its not working for me. My exact requirement is the below one. It is possible to spider webpages from the command line, using the syntax: php spider.php <options> where <options> are -all Reindex everything in the database -u <url> Set the url to index -f Set indexing depth to full (unlimited depth) -d <num> Set indexing depth to <num> -l Allow spider to leave the initial domain -r Set spider to reindex a site -m <string> Set the string(s) that an url must include (use \n as a delimiter between multiple strings) -n <string> Set the string(s) that an url must not include (use \n as a delimiter between multiple strings) If you want to reindex the website url, use php spider.php -u http://www.domain.com/test.html -r I am not having cron settings option in my server. So, I need to run it through a php file in the admin panel while clicking a link. Kindly let me know your valuable suggestions to achieve this. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
effigy Posted December 12, 2007 Share Posted December 12, 2007 Always check the return value. Redirecting STDERR may help also: echo system('php spider.php -u http://www.domainname.com -r 2>&1', $retval); echo $retval; Quote Link to comment Share on other sites More sharing options...
sureshp Posted December 12, 2007 Author Share Posted December 12, 2007 I tried the above one too, but its not woking here. Kindly let me know that how can i make sure that in my server whether the system and exec() functions are working or not. Thanks! Quote Link to comment Share on other sites More sharing options...
effigy Posted December 12, 2007 Share Posted December 12, 2007 You see nothing at all? How about... echo system('echo "test"', $retval); echo $retval; Quote Link to comment Share on other sites More sharing options...
sureshp Posted December 12, 2007 Author Share Posted December 12, 2007 While I am running the above code, I got the below output. test test0 What do you think? Thanks ! Quote Link to comment Share on other sites More sharing options...
effigy Posted December 12, 2007 Share Posted December 12, 2007 Good. Now try: system('which php 2>&1'); Quote Link to comment Share on other sites More sharing options...
sureshp Posted December 12, 2007 Author Share Posted December 12, 2007 Now, the output is /usr/bin/php Quote Link to comment Share on other sites More sharing options...
trq Posted December 12, 2007 Share Posted December 12, 2007 Now try.... <?php echo system('/usr/bin/php spider.php -u http://www.domainname.com -r 2>&1', $retval); echo $retval; ?> Quote Link to comment Share on other sites More sharing options...
sureshp Posted December 13, 2007 Author Share Posted December 13, 2007 THis is the output I am getting this time. Status: 0 Content-type: text/html Security Alert! The PHP CGI cannot be accessed directly. This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive. For more information as to why this behaviour exists, see the manual page for CGI security. For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page. the manual page. 255 Quote Link to comment 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.