Cron PHP cript with require() and inc()?

software development

#1

Hi All.

I’ve got several scripts that I would like to cron - they are versions of other scripts which execute ‘on the fly’. All of the scripts have what I call ‘modules’ - bits of code that get used time and again (e.g., colour definitions for GD, an INC file to connect to mySQL, header and footer type stuff). These are always called by INCLUDE or REQUIRE calls (so I only have to update one piece of code if I decide I want lines to be red instead of darkred, say).

I also like to keep prying eyes off my code as much as possible, so a normal PHP script that is activated by, say, a weblink, will actually call a script (say ‘xyz.php’) which is just an include call to xyz.inc in a protected directory… xyz.inc does the actual work.

Anyhow… cron can’t ‘do’ relative paths. So if you have a PHP script which looks like

<?php require_once("../dira/dbcalls.inc"); include("../dirb/does_stuff.inc"); ... other PHP stuff (and other relative-path includes) ... ?>

Then you’re stuck if you want to cron it… even putting in an

ini_set(“include_path”, “/home/.server/accountname/yourdomain.com”);

into the initial calling script doesn’t seem to do the job (although it SHOULD set the include_path to the base directory of the site, and so should mean that one can reference relative to that).

Anybody got any ideas how to ‘tweak’ to enable relative referencing? That would help me get around having to recode every script that I want to cron (basically would involve rewriting any script that I wanted to cron, carefully copying in the include file contents wherever there is an include… the likelihood of stuffup is enormous).

Thanks in advance - if someone gets me to a solution that works and gets me out of the laborious copy-and-paste described above, I will buy them dinner anytime they are in Paris.

Cheerio,

GT


#2

Duh… how stupid am I? I hear you ask.

All I had to do was cURL the desired php scripts instead of PHPing them. Somewhere in the deep dark dank recesses of my skull I knew that i had done it before (cron’d PHP scripts that included other modules) and I eventually found he cron notification from one of those times (four years ago… shows how long it’s been since I tried to do anything interesting).

Sorry folks, the prize is off the table.

Cheers,

GT