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 lawrence k on 12/22/05 07:34

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
> change your cron entry to:
>
> */15 * * * * /path/to/php /path/to/makeRss.php
>
> ... as I'm assuming it's currently something like:
>
> */15 * * * * /path/to/makeRss.php

Thanks so much for all your help. I took the second route you here
suggest. And I got it to work, for the most part. The RSS feeds are
being created. However, the script is not allowed to run chmod() when
it is called by cron, though it has no problem running chmod() when it
is called from the browser. Why would that be? Is the user different?
Is the user Apache when it is called from the browser, and PHP when
called as a shell script? If so, I assume PHP lacks the rights to
overwrite what Apache did?

It also says gethostbyaddr() is not working. I don't know why. It seems
to work when the script is called from the browser.


I'm getting this, which confirms success but also has error messages:



Content-type: text/html
X-Powered-By: PHP/4.3.2
Set-Cookie: machineId=2173643fecddb17b14e53376e348e98c; expires=Sun,
16-Apr-2006
23:00:40 GMT

<br />
<b>Warning</b>: gethostbyaddr(): Address is not a valid IPv4 or IPv6
address in
<b>/home/httpd/vhosts/autostratus.com/httpdocs/tagIndexLibrary.php</b>
on line <b>74</b><br />
<br />
<b>Warning</b>: chmod(): Operation not permitted in
<b>/home/httpd/vhosts/autostratus.com/httpdocs/tagIndexLibrary.php</b>
on line <b>1530</b><br />

<p><a href="rss/music.xml">We just created the file rss/music.xml</a>
<br />
<b>Warning</b>: chmod(): Operation not permitted in
<b>/home/httpd/vhosts/autostratus.com/httpdocs/tagIndexLibrary.php</b>
on line <b>1530</b><br />

<p><a href="rss/critical_mass_consciousness.xml">We just
created the file rss/critical_mass_consciousness.xml</a>
<br />
<b>Warning</b>: chmod(): Operation not permitted in
<b>/home/httpd/vhosts/autostratus.com/httpdocs/tagIndexLibrary.php</b>
on line <b>1530</b><br />

 

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

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