data.txt
Kod: Označi sve
tekst koj treba da se iscita
drugi red teksta
treci red tekstaKod: Označi sve
#include <stdio.h>
#include <stdlib.h>
#define DATAFILE "../data/data.txt"
int main(void)
{
FILE *f = fopen(DATAFILE,"r");
int ch;
if(f == NULL) {
printf("%s%c%c\n",
"Content-Type:text/html;charset=utf-8",13,10);
printf("<title>nezgodno</title>\n");
printf("<p><em>nisam u mogucnosti da otvorim data fajl, sorry!</em></p>"); }
else {
printf("%s%c%c\n",
"Content-Type:text/plain;charset=utf-8",13,10);
while((ch=getc(f)) != EOF)
putchar(ch);
fclose(f); }
return 0;
}Kod: Označi sve
gcc data.c -o data.cgiPromenimo dozvole u izvrsne i promenimo ownership:
Kod: Označi sve
chmod a+x /var/www/cgi-bin/data.cgi
chown -R www-data:www-data /var/www/cgi-bin/data.cgihttp://localhost/cgi-bin/data.cgi
se treba iscitati sadrzaj data.txt fajla !!!