Run PHP scripts standalone

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

Post Reply
Jacobus
Forum Newbie
Posts: 5
Joined: Sun Jan 12, 2003 2:52 am
Location: Berlin, Germany
Contact:

Run PHP scripts standalone

Post by Jacobus »

Is there an interpreter to do that? I have a case in which I have to run a script in a certain time interval (once every three hours), which is being done using cron. I could (of course) code in perl, but I was just wondering if there's some standalone interpreter around.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you might be interested in http://www.php.net/manual/en/features.commandline.php
Maybe you already have /usr/bin/php
If not and if you're not willing to recompile the whole package without any webserver-support (which should by default create /usr/bin/php) you might use lynx -dump http://url.of/script to invoke your script via cron
Jacobus
Forum Newbie
Posts: 5
Joined: Sun Jan 12, 2003 2:52 am
Location: Berlin, Germany
Contact:

Post by Jacobus »

Ah, thank you. So it will only be possible on systems running the latest version of PHP. Unfortunately the host is running a board system written in PHP (WWWThreads), and as the variable passing has been changed with version 4.2, I fear the whole board system will stop to work, as well as a lot of pages written by different people. Perl it will be then. :?
Jacobus
Forum Newbie
Posts: 5
Joined: Sun Jan 12, 2003 2:52 am
Location: Berlin, Germany
Contact:

Post by Jacobus »

And, it has to stay on that server, because it has some file handling to do, parsing the contents of files, and putting it to a local database.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you still can switch back to the old mechanism by enabling register_globals = On in your php.ini
You might also install a second version of php for testing purposes changing the base path when calling ./configure for the source package.
./configure --help will provide more details.
Jacobus
Forum Newbie
Posts: 5
Joined: Sun Jan 12, 2003 2:52 am
Location: Berlin, Germany
Contact:

Post by Jacobus »

Ok, I'll look into it. Thanks again.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you really should consider an update since some (serious security) fixes took place since then ;)

http://www.php.net/ChangeLog-4.php and then search for fixed
Jacobus
Forum Newbie
Posts: 5
Joined: Sun Jan 12, 2003 2:52 am
Location: Berlin, Germany
Contact:

Post by Jacobus »

Though you're probably right: it's not my machine...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

then you're probably stucked with lynx -dump. But calling a script via http://localhost/script.php that is restricted to localhost by <LIMIT ...> in .htaccess should be sufficient ;)
Post Reply