How to execute a cgi at another server and treat the result

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
Claudio
Forum Newbie
Posts: 1
Joined: Tue Feb 11, 2003 12:15 pm

How to execute a cgi at another server and treat the result

Post by Claudio »

My friends,

I wanna make a little code with a loop executing a cgi program at anoter
server ( like http://www.x.com/test.cgi?par1=b, where "b" will have the
loop's value )

This cgi will return a web page, wich I'd like to treat and pick a little part of it.

The doubts are:

- How execute a cgi at another server?
- How treat the result of it?

Best regards,
Claudio
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

You aren't really executing the script on the other server, you are just accessing it thru the web, the other server will execute it and return its result, you can use that result in your script..

Code: Select all

<?php
  $result = implode ('', file ('http://example.com/some.cgi?beer=samadams'));
  # do something with $result
?>
If you are using PHP 4.3 or newer you can use $r = file_get_contents ('http://site/'); instead
Post Reply