Jump to content


Photo

Crontab and PHP script


  • Please log in to reply
5 replies to this topic

#1 All4172

All4172
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 15 July 2006 - 03:14 AM

I'm able to run the file fine through the browser, but it doesn't seem to be able to be executed by the crontab.  I end up getting:

/home/path/public_html/list.php: line 1: ?php: No such file or directory
/home/path/public_html/list.php: line 3: syntax error near unexpected token `('
/home/path/public_htmllist.php: line 3: `if ($handle = opendir('/home/empirer1/public_html/marketwire')) {'

I've double and triple checked the path (copied the path out of the file in fact).  Any ideas?

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 03:16 AM

i had this problem too.  it's running from the shell (if i remember the problem correctly), so you need to add a line to tell it to use php to parse the file.  the line i used was:

#!/usr/bin/php -q

add that to the top of the file and give it a whirl.  the path might need to be changed.

#3 All4172

All4172
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 15 July 2006 - 03:18 AM

Ok thanks.  Add that to the top of the PHP file?  Like:

#!/usr/bin/php -q
<?php
code.....


#4 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 15 July 2006 - 03:19 AM

yep, that's what did it for me.

#5 All4172

All4172
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 15 July 2006 - 03:26 AM

Thanks that seems to of worked for me to :)

#6 All4172

All4172
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 15 July 2006 - 04:47 AM

Any idea how to make it works with something like script.cgi?login=1&un=2........

I found this php script but the cron tab returns a "This program can only be run through a web server." when it runs.  Although when running it through a browser it works.

#!/usr/bin/php -q
<?PHP
    putenv('QUERY_STRING=login=1&id=100&pw=admin100');
    passthru("/home/path/public_html/cgi-bin/exec/admin.cgi");
?>






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users