CGI
Common Gateway Interface
Back-end, web server, technology.
- Learn, Guides,...
- Libraries with scripts
- See also HTTP error codes when a CGI fail to execute appropriately
- Examples (< may fail depending on server config - if dir listing is allowed or not) (all direct links below opens in a sep. window/tab):
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 |
| 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> |
Updated 2008-08-25
