Hi,
gib mal folgendes in eine script ein, leg sie ausführbar!!! auf deinen webserver und ruf sie dann im browser auf:
#!/bin/bash
echo "Content-Type: text/html"
echo ""echo "Test"
ps ax
_____________________________________________________
Das ps ax is bloß mal so zum spaß ;-). Auf meinem Webserver wird das ganze ausgeführt *freu* Jetzt muß ich das bloß noch interaktiv hinbekommen.
Und vor allem etwas mehr nach Vorschrift:
---snip---
#!/bin/sh
date=date -u '+%a, %d %b %Y %H:%M:%S %Z'
cat << EOF
Content-type: text/plain
Expires: $date
EOF
echo Schreibe in Datei foobar
echo "bla" > foobar
ls -l
echo Lese aus Datei foobar
cat foobar
echo
if [ "$CONTENT_LENGTH" != "" ] ; then
if [ "$CONTENT_LENGTH" -ne 0 ] ; then
echo 'Input:'
echo
dd bs=1 count=$CONTENT_LENGTH
echo
fi
fi
---snap---
$ telnet localhost 80
GET /cgi-bin/printenv HTTP/1.0
HTTP/1.0 200 OK
Content-type: text/plain
Expires: Wed, 18 Aug 2004 08:37:32 UTC
Schreibe in Datei foobar
printenv: foobar: Permission denied
total 4692
-rwxr-xr-x 1 root root 1622083 Aug 18 09:57 phf
-r-xr-xr-x 1 root root 431 Aug 18 10:34 printenv
-rwxr-xr-x 1 root root 1564839 Aug 18 09:57 redirect
-rwxr-xr-x 1 root root 1602281 Aug 18 09:57 ssi
Lese aus Datei foobar
cat: foobar: No such file or directory
Connection closed by foreign host.
Wie Du siehst: _ganz_ so einfach ist das nicht ;-)
Für CGI mit Shellscripten hat übrigens schon jemadn 'was gebastelt, nur ist das nicht mehrzu finden ... ah, Google sei dank, es gibt jede Menge Kopien ;-)
Erster Link bei Google:
http://darkwing.uoregon.edu/~jqj/cgi-bin/proccgi.c
Diese Kopie ist ncht sauber, in Zeile 166
fprintf (stdout, "%s="", data, p2=ptr+1);
Ist nicht ganz korrekt, muß
fprintf (stdout, "%s="", data);p2=ptr+1;
heißen.
---snip---
#!/bin/sh
date=date -u '+%a, %d %b %Y %H:%M:%S %Z'
cat << EOF
Content-type: text/plain
Expires: $date
EOF
if [ "$CONTENT_LENGTH" != "" ] ; then
if [ "$CONTENT_LENGTH" -ne 0 ] ; then
QUERY=dd bs=1 count=$CONTENT\_LENGTH 2>/dev/null
fi
fi
echo QUERY = "$QUERY"
---snap---
$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
POST /cgi-bin/printenv HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 10
HTTP/1.0 200 OK
Content-type: text/plain
Expires: Wed, 18 Aug 2004 10:08:30 UTC
test=12345
QUERY = "test=12345"
Connection closed by foreign host.
Was Du mit dem String dann anfängst bleibt Dir überlassen ;-)
so short
Christoph Zurnieden