Log in

View Full Version : Backend CGI script..



Benzoa
11-09-2006, 06:10 PM
i need a good simple exmaple of a Backend CGI script for somthing im doing in school... so.. ya.. just an example.

ItsMeOnly
11-09-2006, 06:18 PM
backend to what? and _in_ what? (executable? script? batch? perl? php?)

#!/bin/sh
echo "Content-type: text/plain"
echo
echo "Hello World"

Twey
11-09-2006, 06:48 PM
CGI can be written in any language that supports stream output and execution via a shell. A few examples would include:
#!/usr/bin/env perl
print "Content-Type: text/plain\r\n\r\nHello, world";
#!/usr/bin/env python
print "Content-Type: text/plain\r\n\r\nHello, world"
#!/usr/bin/env php
<?php header('Content-Type: text/plain'); ?>
Hello, world
#!/usr/bin/env tclsh
echo "Content-Type: text/plain\r\n\r\nHello, world"
int main(int argc, char **argv) {
printf("Content-Type: text/plain\r\n\r\nHello, world");
return 0;
}
#include <iostream>

int main(int argc, char **argv) {
std::cout << "Content-Type: text/plain\r\n\r\nHello, world";
return 0;
}
section .data
txt db "Content-Type: text/plain", 0xD, 0xA, 0xD, 0xA, "Hello, world"
txtlen equ $ - txt

section .text
global _start
_start:
mov edx, txtlen
mov ecx, txt
mov ebx, 1
mov eax, 4
int 0x80

mov ebx, 0
mov eax, 1
int 0x80The latter three must obviously be compiled/assembled and linked before use.

BLiZZaRD
11-10-2006, 08:19 AM
Are we doing kid's homework now? ROTF

Twey
11-10-2006, 12:59 PM
I presumed that the example was to help him/her, rather than being the whole assignment. Was I wrong?

BLiZZaRD
11-11-2006, 10:52 AM
I don't know, just the feeling I got when I read the OP. Seen it a few times from tech schools, specially from first assignments or finals due.. they come in and want something "explained" to them, then they continue to ask questions like they don't get it until someone just comes and posts the whole thing, they then copy that and turn it in.

Not saying that is what is happening here, just a feeling I got :)