comgt
cee oh em gee tee - "commgitt"
Login to access.
User: pw: ?

CGI

Common Gateway Interface

Back-end, web server, technology.

printenv.pl:

#!/usr/local/bin/perl -wT

use strict;
use diagnostics;

$|++;

print "Content-Type: text/html\n\n";
print "<HTML><HEAD><TITLE>Printenv Script</TITLE></HEAD>\n";
print "<BODY>\n";
print map { "<P><B>$_</B> = $ENV{$_}</P>\n" } sort keys %ENV;
print "</BODY></HTML>\n";

$$$. dd

ddd

Results from another printenv script, as static text, actual execution - only works if server is configured accordingly (not on Internet): http://localhost:8888/cgi-bin/printenv.

 

400 Bad Request

500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

A Mac-encoded text file - uses CR for line breaks
cmdprompt> less printenv.cgi
#!/usr/local/bin/perl -wT^M^Muse strict;^Muse diagnostics;^M^M$|++;^M^Mprint "Co
ntent-Type: text/html\n\n";^Mprint "<HTML><HEAD><TITLE>Printenv Script</TITLE></
HEAD>\n";^Mprint "<BODY>\n";^Mprint map { "<P><B>$_</B> = $ENV{$_}</P>\n" } sort
keys %ENV;^Mprint "</BODY></HTML>\n";
A UNIX (and DOS)-encoded text file - uses LF for line breaks
cmdprompt> less printenv.pl 
#!/usr/local/bin/perl -wT
use strict;
use diagnostics;
$|++;
print "Content-Type: text/html\n\n";
print "<HTML><HEAD><TITLE>Printenv Script</TITLE></HEAD>\n";
print "<BODY>\n";
print map { "<P><B>$_</B> = $ENV{$_}</P>\n" } sort keys %ENV;
print "</BODY></HTML>\n";
[johan@jp2] comgt/search> 	

 

 

PHP as
CGI
PHP as
Module
Script file    
  Must have Executable flag set Yes, get Internal error otherwise No
 
#!/usr/bin/env php
<?php print "Content-Type: text/html\n\n";?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<?php
print "Hello, World\n"; ?> </body> </html>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<?php
print "Hello, World\n"; ?> </body> </html>
 

Running the above script in Module-mode will provide browser output:

#!/usr/bin/env php Content-Type: text/html  Hello, World

 

Test material/script php-as-cgi / show_env.php php-as-cgi / show_env.php

php.net .. reserved.variables.php

   

 

per (2016-02-03) 1&1 IM2713
     
Server API CGI/FastCGI Apache 2.0 Handler

 

 

Updated 2016-02-03