Page 1 of 1

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

Posted: Tue Feb 11, 2003 12:15 pm
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

Posted: Tue Feb 11, 2003 1:12 pm
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