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
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!

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.