faqts : Computers : Programming : Languages : PHP : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

88 of 144 people (61%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How do I execute a CGI script from PHP?

Jul 5th, 2000 20:07
Philip Olson, Matt Gregory, Corky Williams, landon@bradshaw.org


The simplest way to call an external cgi script:
  <?
      $result = exec("myprogie.cgi < $myinput 2>&1");
      print($result);
  ?>
(<p><i>STDERR</i> is not handled and any output to will be passed to 
the browser as part of the page.</p> <p>To stop this from happening you 
can append '2>&1' on the end of your command-line to redirect STDERR to 
STDOUT.</p>)
Another way to do this (better?) is as follows :
  <?
    echo @join (@file ("http://you.com/foo.pl"),"")
  ?>