By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,724 Members | 1,868 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,724 IT Pros & Developers. It's quick & easy.

what does the error " bad interpreter" mean?

P: n/a

I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:

#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:

lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php

bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?

The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.

Feb 9 '08 #1
Share this Question
Share on Google+
16 Replies


P: n/a
lawrence k schreef:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:

#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:

lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php

bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?

The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.
it means you got the wrong interpreter
try:
$ whereis php
php: /usr/bin/php

then replace '/usr/share/php5' with '/usr/bin/php'
--
Luuk
Feb 9 '08 #2

P: n/a
On Feb 9, 3:26 pm, Luuk <L...@invalid.lanwrote:
lawrence k schreef:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:
lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php
bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?
The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.

it means you got the wrong interpreter
try:
$ whereis php
php: /usr/bin/php

then replace '/usr/share/php5' with '/usr/bin/php'

What I get:

lkrubner@programmerpc3:/usr/share$ whereis php
php:
lkrubner@programmerpc3:/usr/share$
Feb 9 '08 #3

P: n/a
On Feb 9, 3:26 pm, Luuk <L...@invalid.lanwrote:
lawrence k schreef:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:
lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php
bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?
The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.

it means you got the wrong interpreter
try:
$ whereis php
php: /usr/bin/php

then replace '/usr/share/php5' with '/usr/bin/php'

The Synaptic Package Manager also tells me that php5 is in /usr/share/

Mind you, my machine didn't have PHP installed till today. I just used
the Synaptic Package Manager to install it.

Feb 9 '08 #4

P: n/a
The Synaptic Package Manager also tells me that php5 is in /usr/share/

Strange. My Xubuntu machine just has it on /usr/bin/php. Did you try to
set the first line to
#!/usr/bin/php
?

Good luck!
Feb 9 '08 #5

P: n/a
On Feb 9, 6:23 pm, Dikkie Dik <dik...@nospam.orgwrote:
The Synaptic Package Manager also tells me that php5 is in /usr/share/

Strange. My Xubuntu machine just has it on /usr/bin/php. Did you try to
set the first line to
#!/usr/bin/php
Doesn't seem possible that would work if both whereis and the Synaptic
Package Manager are suggesting a different address, but just for the
hell of it, I gave it a try. No dice:
lkrubner@programmerpc3:/usr/share$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php

bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/bin/
php: bad interpreter: No such file or directory

Feb 9 '08 #6

P: n/a
On Feb 9, 3:05 pm, lawrence k <lkrub...@geocities.comwrote:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:

#!/usr/share/php5
<?php
echo "hello";
?>

In a terminal window, I try to execute this, and I get a "bad
interperter" error:

lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php

bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied

What does that mean?

The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.
Is there just one interpreter? Do shell scripts use the same
interpreter as what runs through an Apace server?

Feb 9 '08 #7

P: n/a
lawrence k wrote:
On Feb 9, 3:05 pm, lawrence k <lkrub...@geocities.comwrote:
>I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:

#!/usr/share/php5
<?php
echo "hello";
?>

In a terminal window, I try to execute this, and I get a "bad
interperter" error:

lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php

bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied

What does that mean?

The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.

Is there just one interpreter? Do shell scripts use the same
interpreter as what runs through an Apace server?

No. Shell scripts are not PHP, and do not use the PHP interpreter.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Feb 10 '08 #8

P: n/a
lawrence k <lk******@geocities.comwrote:
>
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:

#!/usr/share/php5
<?php
echo "hello";
?>

In a terminal window, I try to execute this, and I get a "bad
interperter" error:

lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php

bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied

What does that mean?

The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.
Are you sure php5 is the executable for the interpreter, and not the
directory that contains the interpreter? What does this tell you?

ls -l /usr/share/php5
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Feb 10 '08 #9

P: n/a
On Feb 9, 9:53 pm, Tim Roberts <t...@probo.comwrote:
lawrence k <lkrub...@geocities.comwrote:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:
lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php
bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?
The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.

Are you sure php5 is the executable for the interpreter, and not the
directory that contains the interpreter? What does this tell you?

ls -l /usr/share/php5
Nice catch. I feel like an idiot:

lkrubner@programmerpc3:/usr/share/php5$ ls -al
total 52
drwxr-xr-x 2 root root 4096 2008-02-09 14:24 .
drwxr-xr-x 308 root root 8192 2008-02-09 14:24 ..
-rw-r--r-- 1 root root 40467 2007-11-28 17:33 php.ini-dist
But what the hell is php.ini-dist?

Feb 10 '08 #10

P: n/a
On Feb 9, 9:53 pm, Tim Roberts <t...@probo.comwrote:
lawrence k <lkrub...@geocities.comwrote:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:
lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php
bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?
The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.

Are you sure php5 is the executable for the interpreter, and not the
directory that contains the interpreter? What does this tell you?

ls -l /usr/share/php5

If I change the script to this:

#!/usr/share/php5/php.ini-dist
<?php
echo "hello";
?>
I still get the same error:

lkrubner@programmerpc3:/usr/share/php5$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php

bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5/php.ini-dist: bad interpreter: Permission denied
and when I run whereis, I get nothing:

lkrubner@programmerpc3:/$ whereis php
php:
lkrubner@programmerpc3:/$


Feb 10 '08 #11

P: n/a
On Feb 9, 9:21 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
lawrence k wrote:
On Feb 9, 3:05 pm, lawrence k <lkrub...@geocities.comwrote:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:
lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php
bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?
The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.
Is there just one interpreter? Do shell scripts use the same
interpreter as what runs through an Apace server?

No. Shell scripts are not PHP, and do not use the PHP interpreter.

I apologize for misuse of the phrase "shell script", when I meant "PHP
script run at the command line".
Feb 10 '08 #12

P: n/a
lawrence k wrote:
On Feb 9, 9:53 pm, Tim Roberts <t...@probo.comwrote:
>lawrence k <lkrub...@geocities.comwrote:
>>I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:
lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php
bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?
The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.
Are you sure php5 is the executable for the interpreter, and not the
directory that contains the interpreter? What does this tell you?

ls -l /usr/share/php5

Nice catch. I feel like an idiot:

lkrubner@programmerpc3:/usr/share/php5$ ls -al
total 52
drwxr-xr-x 2 root root 4096 2008-02-09 14:24 .
drwxr-xr-x 308 root root 8192 2008-02-09 14:24 ..
-rw-r--r-- 1 root root 40467 2007-11-28 17:33 php.ini-dist
But what the hell is php.ini-dist?

That is just a sample php.ini file. You need to find where your php
executable is located - typically it's name is just 'php' (or 'php.exe
on Windoze).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Feb 10 '08 #13

P: n/a
lawrence k wrote:
On Feb 9, 9:21 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
>lawrence k wrote:
>>On Feb 9, 3:05 pm, lawrence k <lkrub...@geocities.comwrote:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:
lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php
bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?
The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.
Is there just one interpreter? Do shell scripts use the same
interpreter as what runs through an Apace server?
No. Shell scripts are not PHP, and do not use the PHP interpreter.


I apologize for misuse of the phrase "shell script", when I meant "PHP
script run at the command line".
OK, now that we're more clear - no, typically the Apache version uses a
module (or, occasionally, a CGI executable) while the command line uses
a non-cgi executable (although the cgi executable can be used).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Feb 10 '08 #14

P: n/a
lawrence k wrote:
On Feb 9, 9:53 pm, Tim Roberts <t...@probo.comwrote:
>lawrence k <lkrub...@geocities.comwrote:
>>I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:
lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php
bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?
The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.
Are you sure php5 is the executable for the interpreter, and not the
directory that contains the interpreter? What does this tell you?

ls -l /usr/share/php5


If I change the script to this:

#!/usr/share/php5/php.ini-dist
<?php
echo "hello";
?>
I still get the same error:

lkrubner@programmerpc3:/usr/share/php5$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php

bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5/php.ini-dist: bad interpreter: Permission denied
and when I run whereis, I get nothing:

lkrubner@programmerpc3:/$ whereis php
php:
lkrubner@programmerpc3:/$


That's just because it's a sample .ini file, as I said. It is not an
executable.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Feb 10 '08 #15

P: n/a
On Feb 9, 9:53 pm, Tim Roberts <t...@probo.comwrote:
lawrence k <lkrub...@geocities.comwrote:
I've never before written a PHP script to run on my home Ubuntu
machine (though I've written dozens of PHP cron jobs for my web
server), so I thought I'd start off with a very simple test:
#!/usr/share/php5
<?php
echo "hello";
?>
In a terminal window, I try to execute this, and I get a "bad
interperter" error:
lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
dailyBackupSpaceBunny.php
bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
php5: bad interpreter: Permission denied
What does that mean?
The php5 interpreter in /usr/share/ has permissions set to 755. Any
script on the machine should be able to execute.

Are you sure php5 is the executable for the interpreter, and not the
directory that contains the interpreter? What does this tell you?

ls -l /usr/share/php5

Well, for anyone else working with Ubuntu, and downloading packages
through the Synaptic Package Manager, be aware that searching for
"PHP5" doesn't get you the command line version of PHP5. You need to
specifically ask for "PHP5-cli".

As others suggested, this gets installed at /usr/bin/php5.

I now changed my script to this:

#!/usr/bin/php5
<?php
echo "hello";
?>
and now it works.

Thanks to everyone for all the help.
Feb 10 '08 #16

P: n/a
On Feb 9, 7:19 pm, lawrence k <lkrub...@geocities.comwrote:
On Feb 9, 9:53 pm, Tim Roberts <t...@probo.comwrote:
lawrence k <lkrub...@geocities.comwrote:
>I've never before written a PHP script to run on my home Ubuntu
>machine (though I've written dozens of PHP cron jobs for my web
>server), so I thought I'd start off with a very simple test:
>#!/usr/share/php5
><?php
>echo "hello";
>?>
>In a terminal window, I try to execute this, and I get a "bad
>interperter" error:
>lkrubner@programmerpc3:/$ /home/lkrubner/cron_jobs/
>dailyBackupSpaceBunny.php
>bash: /home/lkrubner/cron_jobs/dailyBackupSpaceBunny.php: /usr/share/
>php5: bad interpreter: Permission denied
>What does that mean?
>The php5 interpreter in /usr/share/ has permissions set to 755. Any
>script on the machine should be able to execute.
Are you sure php5 is the executable for the interpreter, and not the
directory that contains the interpreter? What does this tell you?
ls -l /usr/share/php5

Well, for anyone else working with Ubuntu, and downloading packages
through the Synaptic Package Manager, be aware that searching for
"PHP5" doesn't get you the command line version of PHP5. You need to
specifically ask for "PHP5-cli".

As others suggested, this gets installed at /usr/bin/php5.

I now changed my script to this:

#!/usr/bin/php5
<?php
echo "hello";
?>

and now it works.

Thanks to everyone for all the help.
just fyi: the "bad interpreter" error can also occur if you wrote a
script on windows and tried to run it on linux. It doesn't like the
\r on that same line, apparently.
Feb 10 '08 #17

This discussion thread is closed

Replies have been disabled for this discussion.