从浏览器调用PHP脚本时工作正常但不是shell脚本
我有一个名为makeRss.php的脚本。如果我尝试使用我的浏览器打开它/ b $ b,它工作正常。它为我网站上的每个页面生成RSS源。你可以看到它在这里工作:
http://www.autostratus.com/index.php?whatPage=makeRss
这就是我想做的事情。
但是,我需要每15分钟调用一次这个脚本。所以我
将其设置为cron作业。而cron并不喜欢称这件事。 Cron
非常好,可以给我发送一封错误消息的电子邮件。每15分钟我就得到这个:
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php:第1行:?php:
没有这样的文件
或目录
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php:第2行:语法
附近错误
意外令牌`" tagIndexLibrary.php"''
/home/httpd/vhosts/autostratus.com/httpdocs/ makeRss.php:第2行:
`include_once(" tagIndexLibrary.php");
如果脚本在网络上正常运行,为什么cron会出现问题? />
浏览器?
I''ve got a script called makeRss.php. It works fine if I try to open it
with my browser. It makes an RSS feed for every page on my site. You
can see it working here:
http://www.autostratus.com/index.php?whatPage=makeRss
It does just what I want it to do.
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 file
or directory
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php: line 2: syntax
error near
unexpected token `"tagIndexLibrary.php"''
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php: line 2:
`include_once("tagIndexLibrary.php");
Why would cron have a problem if the script works fine from the web
browser?
2005年12月21日09:06:53 -0800,lawrence k < LK ****** @ geocities.com>写道:
On 21 Dec 2005 09:06:53 -0800, "lawrence k" <lk******@geocities.com> wrote:
我有一个名为makeRss.php的脚本。如果我尝试用浏览器打开它,它可以正常工作。它为我网站上的每个页面生成RSS源。你可以看到它在这里工作:
http://www.autostratus.com/index.php?whatPage=makeRss
这就是我想要的。
但是,我需要每15分钟调用一次此脚本。所以我把它设置为一个cron工作。而cron并不喜欢称这件事。 Cron
非常好,可以给我发送一封包含错误消息的电子邮件。每隔15分钟我就得到这个:
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php:第1行:?php:
没有这样的fil
I''ve got a script called makeRss.php. It works fine if I try to open it
with my browser. It makes an RSS feed for every page on my site. You
can see it working here:
http://www.autostratus.com/index.php?whatPage=makeRss
It does just what I want it to do.
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
您似乎试图直接运行.php文件。这不行;你需要#b
$ b!在开头行,或者你需要通过PHP运行它。
所以要么:
#!/ path / to / php 作为第一行,当它通过网络运行时会搞砸,或者
将你的cron条目更改为:
* / 15 * * * * / path / to / php /path/to/makeRss.php
......我正在假设它现在是这样的:
* / 15 * * * * /path/to/makeRss.php
-
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space ::磁盘和FTP使用情况分析工具
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
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
在我们的上一集中,
< 11 ********************* @ g49g2000cwa .googlegroups。 com>,
可爱而有才华的劳伦斯k
在comp.lang.php上广播:
In our last episode,
<11*********************@g49g2000cwa.googlegroups. com>,
the lovely and talented lawrence k
broadcast on comp.lang.php:
/ home / httpd / vhosts / autostratus.com / httpdocs / makeRss.php:第1行:?php:
没有这样的文件
或目录
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss。 php:第2行:语法
错误附近
意外令牌`" tagIndexLibrary.php"''
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php:第2行:
`include_once(" tagIndexLibrary.php");
如果脚本在网页浏览器上正常工作,为什么cron会出现问题?
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php: line 1: ?php:
No such file
or directory
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php: line 2: syntax
error near
unexpected token `"tagIndexLibrary.php"''
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php: line 2:
`include_once("tagIndexLibrary.php");
Why would cron have a problem if the script works fine from the web
browser?
可执行文件是PHP,而不是你的PHP脚本。服务器知道
这个。操作系统没有。
你文件的前两个字符必须是#!跟着
马上通过php的路径(不是makeRss.php) - 当我说
说前两个字符时,我的意思是前两个字符带
前面没有空行或空格。或者你可以用你的脚本作为参数从
chron调用php。
-
Lars Eighner us **** @ larseighner.com http://www.larseighner.com/
我的邮件阅读器可以打败你的邮件阅读器。
The executable is php, not your php script. The server knows
this. The operating system does not.
The first two characters of your file need to be #! followed
immediately by the path to php (not makeRss.php) - and when I
say first two characters, I mean the first two characters with
no preceding empty lines or spaces. Or you can call php from
chron with your script as an argument.
--
Lars Eighner us****@larseighner.com http://www.larseighner.com/
My mail reader can beat up your mail reader.
Andy Hassall写道:
Andy Hassall wrote:
2005年12月21日09:06:53 -0800,lawrence k < LK ****** @ geocities.com>写道:
On 21 Dec 2005 09:06:53 -0800, "lawrence k" <lk******@geocities.com> wrote:
但是,我需要每15分钟调用一次这个脚本。所以我把它设置为一个cron工作。而cron并不喜欢称这件事。 Cron
非常好,可以给我发送一封包含错误消息的电子邮件。每隔15分钟我就得到这个:
/home/httpd/vhosts/autostratus.com/httpdocs/makeRss.php:第1行:?php:
没有这样的fil
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
您似乎试图直接运行.php文件。这不行;你需要#!在开头行,或者你需要通过PHP运行它。
所以要么:
#!/ path / to / php
as第一行,当它通过网络运行时会搞砸了,或者
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
我运行phpinfo()找出路径,这是我得到的信息:
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
对不起,我对shell脚本知之甚少,但我无法从
这个地址知道第一行应该是。是这样的:
#!/ sbin / php
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