Cgi execute php script

software development

#1

Hello, I have procmail triggering a cgi script because I can’t get it to trigger a php script. Could I get the cgi script on the mail server to execute a php script on the web server? If so, how? I want to do this because I’m much more fluent with php.


#2

CGI is an interface, not a language. The other interface is CLI “command line interface.” To say something is CGI means it is meant to be run in a CGI environment by a web server and acts a certain way. You can write CGI programs in C for example.

I imagine your “cgi script” is written in Perl. You can execute PHP code the same way. You need a shebang with the path to the PHP executable, execute permissions on the source file, and of course avoid using CGI-specific features. Also you can’t mix HTML within the source file IIRC.

:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


#3

Actually, I just used the exec function in my cgi script. But here’s my next question. How can I pass variables from my cgi script to the php script? I tried exec(“file.php?variable=value”) but it came back saying no such file exists.


#4

Well of course that won’t work - the exec() function is for running commands on the operating system, not for requesting URLs with a query string from a web server over a network.

Since you sound relatively new to programming, here is a tutorial you should read:
Using PHP-CLI (Command Line Interface)

And if you really want to run your PHP script as CGI, then you’re going to have to use an HTTP client like wget or lynx. In other words in Perl you would do:

:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7