Page 1 of 1

need php script to call/run another php script on different

Posted: Sat Nov 27, 2004 7:27 am
by imagineek
I need to setup a php script to call and run another php script that is on a different web server.

Basically, I have cron access on one server, but not on another and want to run a daily report on the server without cron access.

Is there a simply way to do this and how?

example:
- test1.php - lives here: http://www.website1.com/test1.php
- cron job runs test1.php
- test1.php runs and calls test2.php which lives here: http://www.website2.com/test2.php
- test2.php runs and does a simple query and emails results.

how do i call test2.php to run from the other website?

Posted: Sat Nov 27, 2004 12:49 pm
by kettle_drum
The simplest way would be to ignore calling a php script to do it from cron but to just use wget or curl to open the page and call that command in the cron.

Posted: Sat Nov 27, 2004 12:58 pm
by imagineek
kind of like this?

$submit_url = "http://www.website2.com/test2.php";
$ch = curl_init($submit_url);
$result_page = curl_exec($ch);
curl_close ($ch);

Posted: Sat Nov 27, 2004 1:11 pm
by xydon1
you can also call it in a cron job using lynx I believe your syntax would look like this:

lynx -dump http://yoursite.com/yourPhpFile.php

Posted: Sat Nov 27, 2004 5:22 pm
by kettle_drum
Yeah you can do the curl in php like you showed, but you can also just do it from the cron job itself like xydon1 showed - theres no need to create a php script to do it in.

Posted: Sun Nov 28, 2004 8:05 am
by imagineek
Thanks for your help. The lynx -dump works perfectly. Just what I was looking for.