Linux – Command line PHP script no longer working

centoscommand-line-interfacelinuxPHP

A previously working command line PHP script has stopped working – when i run it now it returns this error:

[root@server dir]# ./custom.php
Extension './custom.php' not present.

If i run the script like this it works:

[root@server dir]# php custom.php

For a number of reasons i cannot do this though. I have read something that implies this could be related to line endings but no idea how/why. i have edited this file recently on A Mac and a PC and FTP'd it to the server but i've been doing that for a long time without issues.

EDIT First line of script is:

#!/usr/bin/php -q

FYI The server is running CentOS 5.4

Best Answer

it is generally bad line endings.. using dos line endings. Try using dos2unix on the file and then run it

dos2unix custom.php