473,809 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

a PHP script works fine when called from the browser but not as a shell script

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 `"tagIndexLibra ry.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?

Dec 21 '05
10 2161

Andy Hassall wrote:
On 21 Dec 2005 09:06:53 -0800, "lawrence k" <lk******@geoci ties.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=21736 43fecddb17b14e5 3376e348e98c; 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_c onsciousness.xm l">We just
created the file rss/critical_mass_c onsciousness.xm l</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 />

Dec 22 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1210
by: Chase | last post by:
I'm working in ASP.NET 2.0 and am having problems with some client side script on my .aspx pages. The script looks like this: <script language=vbscript> function OpenFile(FileToOpen) Set oShell = CreateObject("WScript.Shell") oShell.Run("explorer " & FileToOpen) end function </script>
1
3060
by: Nathan | last post by:
This may be a basic task to some of you perl guru's, but I have a problem getting a perl script i've written, when executed by httpd, to send out an e-mail. Basically, i have a few variables passed into this script, it writes them to a a database, and then its supposed to read the "E-mail list" attached to that database entry and shoot an e-mail off to everyone in that list letting them know that there's been an update. I have what...
2
1966
by: boytheo | last post by:
Hi people, I'm trying to get a script to create a few directories on a webserver, and unzip a file or two. my script works fine locally, when accessed via shell. When accessd via apache, it fails :( What to do?
2
2192
by: peteinglastonbury | last post by:
I'd be most grateful if someone would help me. I hope I'm in the right forum (apologies if not) - I'm not sure whether my problem is CGI or Javascript related. I found a script called BatmoAudiopop.js which opens a pop-up browser window with an audio player when a link is clicked. Basically, it sets the right mime-type depending on the operating system and audio file type, then opens a window with the audio file (passed as a parameter) in...
10
8337
by: gh | last post by:
I have a short JS program that runs fine from the command line: #!/usr/bin/java org.mozilla.javascript.tools.shell.Main print("Hello World"); I saved it as HelloWorld.js. (It's the shabang that makes it a JavaScript program, not the .js.) However, if I start it from Safari or Firefox, I get the following message in the log:
2
7580
by: Michael George Lerner | last post by:
Hi, (Python 2.5, OS X 10.4.10) I have a program called pdb2pqr on my system. It is installed so that "pdb2pqr" is in my path and looks like: #\!/bin/zsh -f /sw/share/pdb2pqr/pdb2pqr.py "$@" When I call it via this script:
1
4414
by: pssraju | last post by:
Hi, I am not sure whether I am posting it in right location as i cant see any shell scripting forum here. Below script works perfectly fine from command line, but when I run through browser I am not getting anything inside my $dt. Because of this its always going inside failure scenario. My procedure is going to return either Success / Failed output. Can anybody tell me where I am messing up. #!/usr/bin/ksh if then ...
2
3254
by: smitanaik | last post by:
i have a java file which i am running through shell script. the syntax that i have used is #! /bin/bash javac Copy.java
7
6241
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke this shell script using the Subprocess module. Here is my code: def resultFromRunning_(command):
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.