CGI (2363B)
1 INTRODUCTION 2 3 Geomyidae has support for running scripts on each request, which will generate 4 dynamic content. 5 6 There are two modes: standard cgi and dynamic cgi. 7 (»CGI« as name was just taken, because that's easier to compare to the web.) 8 9 10 PERMISSIONS 11 12 The scripts are run using the permissions of geomyidae. It is advised to use 13 the -g and -u options of geomyidae. 14 15 16 BEFOREHAND 17 18 In these examples C: is what the client sends and S: what the server is 19 sending. 20 21 22 CALLING CONVENTION 23 24 Geomyidae will call the script like this: 25 26 % $gopherroot/test.cgi $search $arguments $host $port 27 28 When it is a plain request, the arguments will have these values: 29 30 C: /test.cgi 31 -> $search = "" 32 -> $arguments = "" 33 -> $host = server host 34 -> $port = server port 35 36 If the request is for a type 7 search element, then the entered string by 37 the user will be seen as following: 38 39 C: /test.cgi searchterm (There is a TAB in-between) 40 -> $search = »searchterm« 41 -> $arguments = "" 42 -> $host = server host 43 -> $port = server port 44 45 When you are trying to give your script some calling arguments, the syntax 46 is: 47 48 C: /test.cgi?hello 49 -> $search = "" 50 -> $arguments = »hello« 51 -> $host = server host 52 -> $port = server port 53 54 If both ways of input are combined, the variables are set as following: 55 56 C: /test.cgi?hello=world searchterm (Beware! A Tab!) 57 -> $search = »searchterm« 58 -> $arguments = »hello=world« 59 -> $host = server host 60 -> $port = server port 61 62 63 STANDARD CGI 64 65 The file extension »cgi« switches to this mode, where the output of the 66 script is not interpreted at all by the server and the script needs to send 67 raw content. 68 69 % cat test.cgi 70 #!/bin/sh 71 echo "Hello my friend." 72 % 73 74 The client will receive: 75 76 S: Hello my friend. 77 78 79 DYNAMIC CGI 80 81 For using dynamic CGI, the file needs to end in »dcgi«, which will switch on 82 the interpretation of the returned lines by the server. The interpreted for- 83 mat is the same as in the *.gph files. 84 85 % cat test.dcgi 86 #!/bin/sh 87 echo "[1|Some link|/somewhere|server|port]" 88 % 89 90 Here geomyidae will interpret the *.gph format and return the valid gopher 91 menu item. 92 93 S: 1Some link /somewhere gopher.r-36.net 70 94 95 For outputting large texts and having minor hassles with the content, prepend 96 »t« to every line beginning with »t« or all lines: 97 98 % cat filereader.dcgi 99 #!/bin/sh 100 cat bigfile.txt | sed 's,^t,&&,' 101 102 Have fun! 103