Run PHP script from Linux Shell

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Take the command out of crontab & run in manually - see what happens.

While we're not sure what the problem is, I'm 100% confident that the problem is with your code/call to php & not crontab/SuSE.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
ferreira.jorge
Forum Newbie
Posts: 11
Joined: Tue Nov 14, 2006 6:13 am
Location: Portugal

Post by ferreira.jorge »

Ok.
I tried to run it from shell like you told me.
If i run this command like a normal shell script

Code: Select all

# ./script.php
it says to me the same thing it does in crontab, which is:

Code: Select all

.ould not open input file:
If i try to run it from shell like

Code: Select all

# php script.php
it runs it properly.
Does this help? I'm really getting desperate.

Thanx for your help
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Sorry, I should have been more specific. Run it as 'root' since that's what its being run as in cron.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
ferreira.jorge
Forum Newbie
Posts: 11
Joined: Tue Nov 14, 2006 6:13 am
Location: Portugal

Post by ferreira.jorge »

Well, I did.
All the messages that I posted up were made while running the scripts as root.
Does it make sense to post all my code here, including all the scripts and the crontab?
Maybe that way we could find something that's not properly coded.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I'm running out of ideas. At this point I'd start with a new file & try to build it up. Make it just a basic echoing PHP file & see if you can get it to run properly. Then add more & more code until you've got what you need.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
ferreira.jorge
Forum Newbie
Posts: 11
Joined: Tue Nov 14, 2006 6:13 am
Location: Portugal

Post by ferreira.jorge »

Yeah. That's what I was thinking too.
Thanx anyway for your time.
Nwalee
Forum Newbie
Posts: 1
Joined: Thu Feb 01, 2007 2:42 pm

Post by Nwalee »

I had a same problem. I figured that my php script file wasn't unix format.
So make sure it's Unix not PC format. This should fix your problem as well.
Post Reply