Fixing “Error: bad interpreter: No such file or directory” in PHP

Posted by Johan Cyprich on 11 Jun 2010 | Tagged as: How To

I prefer using the PDT tools in Eclipse for working with PHP, but a problem that I keep getting when creating new files is that I can’t execute them in Linux. I get the following error message when I run PHP files from the shell:

Error from PHP document created in Eclipse.

When you get an error like this, the first thing to check is if the interpreter is correct in the PHP source code. This is the first line of text and it looks typically like

#! /usr/bin/php

The PHP interpreter’s path can be found by entering which php in the command shell. Unfortunately, this won’t fix the problem for a PHP document created in Eclipse. The files are being saved as DOS files which you can see if you open your document with vi (see below).

Eclipse created a DOS file.

There is no option in the PDT tools to save files as a UNIX type. The best way to do this is go into the command shell and use the dos2unix command:

i.e. dos2unix test.php

This will convert test.php to a UNIX file type and then it can be executed in the shell. If you view it in vi, the [dos] indicator will not be displayed (see below).

The document is now a UNIX file.



Tweet This Tweet This Post!

Related posts:
    Fixing “/var/lib/pgsql/data is missing” Error
    Fixing Database Error 1054 in Fireboard
    Fixing Joomla’s “Unable to find install package”
    How to Install PHP on IIS

Share this post:

del.icio.us:Fixing “Error: bad interpreter: No such file or directory” in PHP digg:Fixing “Error: bad interpreter: No such file or directory” in PHP spurl:Fixing “Error: bad interpreter: No such file or directory” in PHP wists:Fixing “Error: bad interpreter: No such file or directory” in PHP simpy:Fixing “Error: bad interpreter: No such file or directory” in PHP newsvine:Fixing “Error: bad interpreter: No such file or directory” in PHP blinklist:Fixing “Error: bad interpreter: No such file or directory” in PHP furl:Fixing “Error: bad interpreter: No such file or directory” in PHP reddit:Fixing “Error: bad interpreter: No such file or directory” in PHP fark:Fixing “Error: bad interpreter: No such file or directory” in PHP blogmarks:Fixing “Error: bad interpreter: No such file or directory” in PHP Y!:Fixing “Error: bad interpreter: No such file or directory” in PHP smarking:Fixing “Error: bad interpreter: No such file or directory” in PHP magnolia:Fixing “Error: bad interpreter: No such file or directory” in PHP segnalo:Fixing “Error: bad interpreter: No such file or directory” in PHP gifttagging:Fixing “Error: bad interpreter: No such file or directory” in PHP

Follow Me:

Did you find this post interesting and useful? You can keep up to date on this blog by subscribing to my RSS feed, or you can have new posts sent to you by e-mail. You can also follow me on Twitter.


Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply

CommentLuv badge