You are here: Re: a PHP script works fine when called from the browser but not as a shell script « PHP Programming Language « IT news, forums, messages
Re: a PHP script works fine when called from the browser but not as a shell script

Posted by Andy Hassall on 12/22/05 02:05

On 21 Dec 2005 15:32:30 -0800, "lawrence k" <lkrubner@geocities.com> wrote:

>Andy Hassall wrote:
>> On 21 Dec 2005 09:06:53 -0800, "lawrence k" <lkrubner@geocities.com> wrote:
>>
>> >However, I need for this script to get called every 15 minutes. So I
>> >set it up as a cron job. And cron doesn't like calling this thing. Cron
>> >is nice enough to send me an email with an error message. Every 15
>> >minutes I get this:
>> >
>> >/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php: line 1: ?php:
>> >No such fil
>>
>> You seem to be trying to run the .php file directly. This won't work; you
>> either need a #! line at the beginning, or you need to run it via PHP.
>>
>> So either:
>>
>> #!/path/to/php
>>
>> as the first line, which will mess things up when it's run via the web, or
>
>I ran phpinfo() to find out the path, and this is the info I got:
>
>PATH /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
>
>_SERVER["PATH"] /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
>
>_SERVER["PATH_TRANSLATED"] /home/httpd/vhosts/autostratus.com/httpdocs/info.php
>
>_ENV["PATH"] /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
>
>I'm sorry I know so little about shell scripts, but I can't figure from
>this what the address in the first line should be. Is it like this:
>
>#!/sbin/php

Type the following at a shell prompt:

which php

This will tell you the path.

Failing that, use phpinfo(), and look for "--prefix=" in the configure line.
If it's "--configure=/usr", then the CLI version of PHP is at /usr/bin/php.

And you probably don't want to be adding the #! line due to the warnings I
wrote immediately after it. You probably want the second option, changing your
cron entry to call php with the script as an argument.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация