PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 27th, 2004, 07:18 AM
imagineek imagineek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 imagineek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question need php script to call/run another php script on different server

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?

Reply With Quote
  #2  
Old December 29th, 2004, 12:39 AM
dero dero is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 dero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question facing similar problems

Hi,
I am also facing similar problems. Need help.
regards
dero

Reply With Quote
  #3  
Old December 29th, 2004, 09:23 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
You could try some of PHP's file commands, or socket commands...

PHP Code:
<?php
$fp 
fsockopen("www.website2.com"80$errno$errstr30);
if (!
$fp) {
   echo 
"$errstr ($errno)<br />\n";
} else {
   
$out "GET /test2.php HTTP/1.1\r\n";
   
$out .= "Host: www.example.com\r\n";
   
$out .= "Connection: Close\r\n\r\n";

   
fwrite($fp$out);
   while (!
feof($fp)) {
       echo 
fgets($fp128);
   }
   
fclose($fp);
}
?>

Connecting to the script like this will in essence execute the script.
Notice that the path in the fsockopen command is the path to your webserver.
Your filename is found further down in the string containing the HTTP method GET.

In the comment section of the PHP Manual, edwin has posted this function which might make things a little easier for you:
PHP Code:
<?php
function fetchURL$url ) {
   
$url_parsed parse_url($url);
   
$host $url_parsed["host"];
   
$port $url_parsed["port"];
   if (
$port==0)
       
$port 80;
   
$path $url_parsed["path"];
   if (
$url_parsed["query"] != "")
       
$path .= "?".$url_parsed["query"];

   
$out "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";

   
$fp fsockopen($host$port$errno$errstr30);

   
fwrite($fp$out);
   
$body false;
   while (!
feof($fp)) {
       
$s fgets($fp1024);
       if ( 
$body )
           
$in .= $s;
       if ( 
$s == "\r\n" )
           
$body true;
   }
  
   
fclose($fp);
  
   return 
$in;
}
?>


Refer to the Fsockopen command in the PHP Documentation for more information.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > need php script to call/run another php script on different server


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT