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

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
imagineek
Forum Newbie
Posts: 3
Joined: Sat Nov 27, 2004 7:25 am

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

Post 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?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
imagineek
Forum Newbie
Posts: 3
Joined: Sat Nov 27, 2004 7:25 am

Post 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);
xydon1
Forum Newbie
Posts: 3
Joined: Sat Nov 27, 2004 12:55 pm
Contact:

Post 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
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
imagineek
Forum Newbie
Posts: 3
Joined: Sat Nov 27, 2004 7:25 am

Post by imagineek »

Thanks for your help. The lynx -dump works perfectly. Just what I was looking for.
Post Reply