Jump to content

How to run system commands in php?


sureshp

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/81224-how-to-run-system-commands-in-php/
Share on other sites

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!

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!

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.