PDA

View Full Version : command line exec() pulls wrong file (php as cgi?)


kzant
01-31-2005, 09:21 AM
Hi. Thanks for a great product, and for such a helpful forum. I've got phpdig up and running. Instead of running the indexer for the whole site, I want to index each document as it is added/edited to the site by a web-based administrator.

As such, I'd like to use the exec() command within php and index the file as its edited or added.

I've tested the following command via shell and it worked beautifully.

/usr/bin/php -f /path/to/admin/spider.php http://www.site.com/document.doc >> /path/to/spider.log

I check spider.log and see the output of the spider text.

However, when I call from a php script as such:

exec(/usr/bin/php -f /path/to/admin/spider.php http://www.site.com/document.doc >> /path/to/spider.log, $out);

It actually indexes the admin page that calls the exec command, not the document http://www.site.com/document.doc

My php is set to run as cgi - I'm sure this has something to do with it and there is some environment variable that I'm missing.

Any advice is appreciated.

Thanks.

Charter
01-31-2005, 10:53 AM
Perhaps try one of the following...

// save output in spider.log
exec("/usr/bin/php -f /path/to/admin/spider.php http://www.site.com/document.doc >> /path/to/spider.log");

// save output in $out variable
exec("/usr/bin/php -f /path/to/admin/spider.php http://www.site.com/document.doc",$out);

kzant
02-01-2005, 07:14 AM
okay, well fixed that. but its still digging the upload/edit script page and not the document that's being uploaded.

exec("/usr/bin/php -f /path/to/admin/spider.php http://www.site.com/document.doc >> /path/to/spider.log");

Thanks for your prompt response.