bad interpreter error from CLI

bad interpreter error from CLI

am 13.03.2009 15:10:36 von Goltsios Theodore

Hi gang,
I am trying to run a script from cli which goes like this:

#!/usr/bin/php
passthru("printenv");
?>

The error I get is this:
/usr/bin/php^M: bad interpreter: Permission denied

the php binary is indeed in this location and when I run the same script
like this:
php -f test.php

it works properly. I will have to mention that the executable flag is
set in the file's permissions.

Any ideas why is this happening?

php -v gives me:
PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:34)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

--
Thodoris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: bad interpreter error from CLI

am 13.03.2009 15:16:08 von Daniel Brown

On Fri, Mar 13, 2009 at 10:10, Thodoris wrote:
> Hi gang,
> =A0 I am trying to run a script from cli which goes like this:
>
> #!/usr/bin/php
> > passthru("printenv");
> ?>
>
> The error I get is this:
> /usr/bin/php^M: bad interpreter: Permission denied

Note the ^M --- then use dos2unix from the command line on the
Linux box to fix the line endings on that file. The ^M character is a
sure-fire sign of a Windows-saved file.

> the php binary is indeed in this location and when I run the same script
> like this:
> php -f test.php
>
> it works properly. I will have to mention that the executable flag is set=
in
> the file's permissions.
>
> Any ideas why is this happening?
>
> php -v gives me:
> PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:34)
> Copyright (c) 1997-2006 The PHP Group
> Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

The above should no doubt fix it, but in the event that it does
not, check the output from the following command line commands on your
Linux box:

which php
whereis php

The first will tell you which PHP CLI binary is preferred by the
current $PATH settings, while the second will tell you where in $PATH
'php' is located.

--=20

daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: bad interpreter error from CLI

am 13.03.2009 15:23:26 von Goltsios Theodore

--------------030904040007090906010800
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


> Note the ^M --- then use dos2unix from the command line on the
> Linux box to fix the line endings on that file. The ^M character is a
> sure-fire sign of a Windows-saved file.
>
>

Already tried that but I still get the same error (without the ^M of
course) so I think it's not the line termination.

>> the php binary is indeed in this location and when I run the same script
>> like this:
>> php -f test.php
>>
>> it works properly. I will have to mention that the executable flag is set in
>> the file's permissions.
>>
>> Any ideas why is this happening?
>>
>> php -v gives me:
>> PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:34)
>> Copyright (c) 1997-2006 The PHP Group
>> Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
>>
>
> The above should no doubt fix it, but in the event that it does
> not, check the output from the following command line commands on your
> Linux box:
>
> which php
> whereis php
>
> The first will tell you which PHP CLI binary is preferred by the
> current $PATH settings, while the second will tell you where in $PATH
> 'php' is located.
>
>

Both commands return the same path.

--
Thodoris


--------------030904040007090906010800--

Re: bad interpreter error from CLI

am 13.03.2009 15:36:00 von Daniel Brown

On Fri, Mar 13, 2009 at 10:23, Thodoris wrote:
[snip!]
>
> Both commands return the same path.

.... and that path, I'll presume, is the same you have set in the
script, right? Please offer as much information as you can with each
email to speed up the troubleshooting process. ;-P

What's the output you get from the following (copied exactly)?

ls -l /usr/bin/php
ls -l `which php`

--

daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: bad interpreter error from CLI

am 13.03.2009 15:44:35 von Addmissins Development

Thodoris wrote:
> Hi gang,
> I am trying to run a script from cli which goes like this:
>
> #!/usr/bin/php
> > passthru("printenv");
> ?>
>
> The error I get is this:
> /usr/bin/php^M: bad interpreter: Permission denied
>
> the php binary is indeed in this location and when I run the same script
> like this:
> php -f test.php
>
> it works properly. I will have to mention that the executable flag is
> set in the file's permissions.
>
> Any ideas why is this happening?
>
> php -v gives me:
> PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:34)
> Copyright (c) 1997-2006 The PHP Group
> Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
>

Does the filesystem the scripts are on by any chance has 'noexec' set?

$ mount
(rw,noexec,nosuid,nodev)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: bad interpreter error from CLI

am 13.03.2009 15:44:59 von Goltsios Theodore

--------------010701090108030305050208
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


> On Fri, Mar 13, 2009 at 10:23, Thodoris wrote:
> [snip!]
>
>> Both commands return the same path.
>>
>
> .... and that path, I'll presume, is the same you have set in the
> script, right? Please offer as much information as you can with each
> email to speed up the troubleshooting process. ;-P
>
> What's the output you get from the following (copied exactly)?
>
> ls -l /usr/bin/php
> ls -l `which php`
>
>

[root@foo tmp]# ls -l /usr/bin/php
-rwxr-xr-x 1 root root 2702972 Nov 12 16:24 /usr/bin/php

[root@foo tmp]# ls -l `which php`
-rwxr-xr-x 1 root root 2702972 Nov 12 16:24 /usr/bin/php

I did mention that it works using php -f didn't I?
So it actually finds the binary because it is in the path :-) .

--
Thodoris


--------------010701090108030305050208--

Re: bad interpreter error from CLI

am 13.03.2009 16:39:28 von Goltsios Theodore

--------------070308030605070404040204
Content-Type: text/plain; charset=ISO-8859-7; format=flowed
Content-Transfer-Encoding: 7bit


> Thodoris wrote:
>
>> Hi gang,
>> I am trying to run a script from cli which goes like this:
>>
>> #!/usr/bin/php
>> >> passthru("printenv");
>> ?>
>>
>> The error I get is this:
>> /usr/bin/php^M: bad interpreter: Permission denied
>>
>> the php binary is indeed in this location and when I run the same script
>> like this:
>> php -f test.php
>>
>> it works properly. I will have to mention that the executable flag is
>> set in the file's permissions.
>>
>> Any ideas why is this happening?
>>
>> php -v gives me:
>> PHP 5.1.6 (cli) (built: Nov 12 2008 11:22:34)
>> Copyright (c) 1997-2006 The PHP Group
>> Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
>>
>>
>
> Does the filesystem the scripts are on by any chance has 'noexec' set?
>
> $ mount
> (rw,noexec,nosuid,nodev)
>
>



Yes this is the problem !! How did I miss that?
Thanks for the help.

--
Thodoris


--------------070308030605070404040204--