PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > Troubleshooting

Reply
 
Thread Tools
Old 01-13-2005, 03:32 PM   #1
drywall
Green Mole
 
Join Date: May 2004
Posts: 25
command line and ABSOLUTE_SCRIPT_PATH

I've had phpdig up and running on my site for a while, but I've gotten tired of manully spidering, so I decided to look into setting up cron -- which largely appears to be really easy, bravo!

The problem I'm running into is that php spits out a bunch of include warnings when I try to run from the command line... I've no idea why, though I'm pretty sure I've got it set up properly.

My config.php looks like:


define('ABSOLUTE_SCRIPT_PATH','/Library/WebServer/Documents/tools/phpdig');

if ((!isset($relative_script_path)) || (($relative_script_path != ".") &&
($relative_script_path != "tools/phpdig") && ($relative_script_path != "..") && ($relative_script_path != ABSOLUTE_SCRIPT_PATH)))


My search.php isn't located in my phpdig directory, obviously. Anyway, these settings have everything on the website working well. But when I try the following from the command line [yep, I know php's in a slightly unusual place]:


/usr/local/php/bin/php -f /Library/WebServer/Documents/tools/phpdig/admin/spider.php http://www.mydomain.com


I get the following output:


PHP Warning: main(../includes/config.php): failed to open stream: No such file or directory in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 91
PHP Warning: main(): Failed opening '../includes/config.php' for inclusion (include_path='.:/usr/local/php/lib/php') in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 91
PHP Notice: Use of undefined constant USE_RENICE_COMMAND - assumed 'USE_RENICE_COMMAND' in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 93
PHP Warning: main(../admin/robot_functions.php): failed to open stream: No such file or directory in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 112
PHP Warning: main(): Failed opening '../admin/robot_functions.php' for inclusion (include_path='.:/usr/local/php/lib/php') in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 112
PHP Fatal error: Call to undefined function: phpdigprnmsg() in /Library/WebServer/Documents/tools/phpdig/admin/spider.php on line 128


Which seem like the kind of messages I might get if I had ABSOLUTE_SCRIPT_PATH incorrectly set. But I've looked at it a million times and retyped it and I swear it's correct. Any idea what I'm doing wrong here?

Thanks for your help.

Last edited by drywall; 01-13-2005 at 03:35 PM.
drywall is offline   Reply With Quote
Old 01-13-2005, 03:56 PM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
The output is saying that PHP cannot find various files for inclusion WRT this location:
Code:
/Library/WebServer/Documents/tools/phpdig/admin/spider.php
As you seem to have a different directory structure, try setting the following (it's a guess):
PHP Code:
define('ABSOLUTE_SCRIPT_PATH','/Library/WebServer/Documents/tools/phpdig'); 
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 01-13-2005, 07:25 PM   #3
drywall
Green Mole
 
Join Date: May 2004
Posts: 25
whoops

Okay, so you got me... I was actually trying to obscure a little bit the actual path I'm using (just paranoia on my part about disclosing full directory structures). Made the change in what I posted as config but not in the php warnings. But the cat's out of the bag, so I might was well confess... *actual* config.php:


define('ABSOLUTE_SCRIPT_PATH','/Library/WebServer/Documents/tools/phpdig');

if ((!isset($relative_script_path)) || (($relative_script_path != ".") &&
($relative_script_path != "tools/phpdig") && ($relative_script_path != "..") && ($relative_script_path != ABSOLUTE_SCRIPT_PATH)))


And *actual* command I'm using is:


/usr/local/php/bin/php -f /Library/WebServer/Documents/tools/phpdig/admin/spider.php http://www.mydomain.com


Sorry to be misleading and by doing so waste anyone's time. I'm an idiot.
drywall is offline   Reply With Quote
Old 01-13-2005, 11:31 PM   #4
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
OIC, ha ha, anyway... where are the config.php and robot_functions.php files relative to the following:
Code:
/Library/WebServer/Documents/tools/phpdig/admin/spider.php
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 01-14-2005, 06:22 AM   #5
drywall
Green Mole
 
Join Date: May 2004
Posts: 25
The usual...

/Library/WebServer/Documents/tools/phpdig/admin/spider.php
/Library/WebServer/Documents/tools/phpdig/includes/config.php
/Library/WebServer/Documents/tools/phpdig/admin/robot_functions.php

So they seem so to be where they're supposed to be...
drywall is offline   Reply With Quote
Old 01-14-2005, 10:26 AM   #6
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Are you sure "/Library/WebServer/..." is the full path? Maybe you have something like "/dir1/dir2/Library/WebServer/..." for the full path? Try the following script. Does it echo "/Library/WebServer/..." or something else?
PHP Code:
<?php
echo $_SERVER['DOCUMENT_ROOT']."<br>";
echo 
$_SERVER['SCRIPT_FILENAME']."<br>";
echo 
$_SERVER['PATH_TRANSLATED']."<br>";
?>
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 01-14-2005, 11:02 AM   #7
drywall
Green Mole
 
Join Date: May 2004
Posts: 25
Yep, I'm pretty darn sure (I'm basically co-sysadmin for the machine, so I know the dir structure pretty well). The above script outputs:

/Library/WebServer/Documents
/Library/WebServer/Documents/tools/phpdig/test.php
/Library/WebServer/Documents/tools/phpdig/test.php
drywall is offline   Reply With Quote
Old 01-14-2005, 12:00 PM   #8
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
The only other thing I can think of is that it's a permission/ownership/group issue, where it runs from the web interface but not from shell. Check that the PhpDig files have "-rw-r--r--" permission and see if /usr/local/php/bin/php is set with "-rwxr-xr-x" permission. The crontab executable can have "-rws--x--x" permission.

Also, I did think about the php.ini file, perhaps changing:
Code:
include_path = .:/usr/local/php/lib/php
To something like the following:
Code:
include_path = ./:/usr/local/php/lib/php:/Library/WebServer/Documents/tools/phpdig/admin:/Library/WebServer/Documents/tools/phpdig/includes
But that doesn't really seem to be the problem, as you can run PhpDig from the web interface, so it's back to a permission/ownership/group issue.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 01-14-2005, 01:41 PM   #9
drywall
Green Mole
 
Join Date: May 2004
Posts: 25
Those both sounded like very good, promising ideas.

Unfortunately, my perssions were already set to those values, so that wasn't the problem.

Edited my php.ini just to give that a try, and it didn't change anything at all -- still get the same errors.

If I didn't know any better, I'd say that it seems like from the command line spider.php is still trying to use $relative_script_path instead of falling back on the ABSOLUTE_SCRIPT_PATH. That's the only way I can figure it'd work fine from the website but not from the command line... but I could be way off on that one.
drywall is offline   Reply With Quote
Old 01-14-2005, 02:27 PM   #10
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
The $relative_script_path is used throughout the script, but it should be relative to wherever you are in the script. The ABSOLUTE_SCRIPT_PATH is so you can call PhpDig from shell while being outside the admin directory, but once called, the $relative_script_path should be page relative... unless... what's your "doc_root" set to in your php.ini file?
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 01-14-2005, 02:37 PM   #11
drywall
Green Mole
 
Join Date: May 2004
Posts: 25
I had to check and... It's not set to anything.
drywall is offline   Reply With Quote
Old 01-14-2005, 02:48 PM   #12
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hmm, is your /usr/local/php/bin/php running under user root?
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 01-14-2005, 03:01 PM   #13
drywall
Green Mole
 
Join Date: May 2004
Posts: 25
I believe so... it's running as whatever the default is -- pretty sure that's root (but I have to admit I don't know how to check or change that). /usr/local/php/bin/php is owned by root....
drywall is offline   Reply With Quote
Old 01-14-2005, 03:04 PM   #14
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
What's a link to your PHP info?
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 01-14-2005, 03:13 PM   #15
drywall
Green Mole
 
Join Date: May 2004
Posts: 25
Don't wanna be a jerk, but there's some sensitive info on that page... (namely PHP_AUTH_PW) but PHP_AUTH_USER is "xxxxxx" -- anything in particular you want to see on that page?
drywall is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems running command line remc Troubleshooting 2 03-15-2005 09:34 AM
spider from command line twanoo Troubleshooting 3 01-14-2005 11:04 AM
command line using winxp mrgee Troubleshooting 1 11-03-2004 03:20 AM
Command Line entry and nothing happens aslan Troubleshooting 6 08-27-2004 04:19 PM
Indexing by command line... Canadian How-to Forum 4 01-04-2004 07:44 PM


All times are GMT -8. The time now is 02:32 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.