[[cgi]]
 
Table of Contents

Perl

#! /usr/bin/perl
 
print "Content-type: text/plain\n\n";
 
print "This is output from simple Perl script \n";
print "\n";
 
foreach $var (sort(keys(%ENV))) {
    $val = $ENV{$var};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g;
    print "${var}=\"${val}\"\n";
}

C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
void main (void)
{
    char *http_user_agent;
 
    printf ("Content-type: text/plain\n\n");
    http_user_agent = getenv ("HTTP_USER_AGENT");
 
    if (http_user_agent == NULL) {
        printf ("Oops! Your browser failed to set the HTTP_USER_AGENT ");
        printf ("environment variable!\n");
 
    } else if (!strncmp (http_user_agent, "Mosaic", 6)) {
        printf ("I guess you are sticking with the original, huh?\n");
 
    } else if (!strncmp (http_user_agent, "Mozilla", 7)) {
        printf ("Well, you are not alone. A majority of the people are ");
        printf ("using Netscape Navigator!\n");
 
    } else if (!strncmp (http_user_agent, "Lynx", 4)) {
        printf ("Lynx is great, but go get yourself a graphic browser!\n");
 
    } else {
        printf ("I see you are using the %s browser.\n", http_user_agent);
        printf ("I don't think it's as famous as Netscape, Mosaic or Lynx!\n");
    }
 
    exit (0);
}

Oprava

su
cd /local/uzivatel/public_html
chown uzivatel:uzivatel -R priklady
 
cgi.txt · Last modified: 2008/04/02 18:10 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki