Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling acgi script from PHP

Status
Not open for further replies.

JimFL

Programmer
Jun 17, 2005
131
GB
Hi,

I have a problem trying to call a CGI script from PHP index file. The following worked fine using an index.shtml file but it doesnt work once I change the extenstion to index.php . Can this be done simply using a php file?

<html>
<!--#exec cgi='/hitslog/logger.cgi' -->
<head>

Can anybody help?
 
You have to be aware of the nature of server side include calls.
SSI in Apache are resolved by the Apache server itself - once the PHP interpreter takes the PHP code APache is not processing the SSI anymore - PHP processes.
You can easily write PHP code that executes the same CGI script. There are several commands like exec() and passthru(), however, to be safe, I recommend to use virtual() which generates a virtual Apache subrequest that is handled the same way SSI would be. That is safer since all access privileges and .htaccess directives etc. are still resolved by Apache itself.
 
I have re-written the CGI script in PHP to perform a similar function. I was just wondering if there was a quick solution out there.

Thanks for your advice DRJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top