FieldingBlue Posted May 11, 2015 Share Posted May 11, 2015 Hiho,This one has me stumped. I've been coding for a while and never seen this sort of problem before. This issue has occured on an openSuse box. PHP from the command line reports that it is unable to find php files in a particular sub-directory. But everywhere else things work fine. There are no differences that I can identify between permissions. There is no .htaccess file. I've checked the php.ini file and there are no prescriptive settings that prohibit the offending sub-directory. The problem exists even as Super User.Below is the output from a session that highlights my issue. The same test.php file is included in the current directory, a 'test' sub-directory and the offending 'projects' sub-directory.The script permissions are the same in each directory. Also the permissions for the directories are identical.The script is simple.The script contents are the same in each directory.The output is different for the script in the 'projects' sub-directory. Apparently PHP cannot find the file.If anyone has any hints I'd love to hear them.Thanksuser@machine:~> ls -l test.php-rw-r--r-- 1 user users 37 May 11 07:40 test.php user@machine:~> ls -l test/test.php-rw-r--r-- 1 user users 37 May 11 07:41 test/test.php user@machine:~> ls -l projects/test.php-rw-r--r-- 1 user users 37 May 11 07:41 projects/test.phpuser@machine:~> cat test.php<?phpecho "is this thing on?\n";?>user@machine:~> diff test.php test/test.phpuser@machine:~> diff test.php projects/test.php user@machine:~> php test.php is this thing on? user@machine:~> php test/test.php is this thing on? user@machine:~> php projects/test.php PHP Fatal error: Unknown: Failed opening required 'projects/test.php' (include_path='.:/usr/share/php5:/usr/share/php5/PEAR') in Unknown on line 0user@machine:~> Quote Link to comment https://forums.phpfreaks.com/topic/296190-php-cli-unable-to-execute-in-subdir/ Share on other sites More sharing options...
QuickOldCar Posted May 11, 2015 Share Posted May 11, 2015 relative is no leading slash absolute will have a leading slash You don't want to use a relative path, an absolute path of the current directory is what you need If this script isn't running from the same directory it wouldn't be able to find it, so try adding the directory path You can use set_include_path() Some OS are slightly different. In php scripts I add this to locate the directory name and it's separator $full_path = dirname(__FILE__) . DIRECTORY_SEPARATOR."/projects/test.php"; Quote Link to comment https://forums.phpfreaks.com/topic/296190-php-cli-unable-to-execute-in-subdir/#findComment-1511394 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.