comment on 1st week rush, hw1 show last night's 90min effort fill in gaps: get vs. post: secure vs. open, automatic subfunction naming/linking, stdin parsing help vs. failure-to-reset bugs, cleanliness to user vs. robot/spider access can't use both at same time (unless browser is nonstandard) can use ENVIRON cookies and post at same time can have a script which responds to both (invoke with form/post or URL/get) debugging hints: print your data as it arrives, then exit note special characters in your data test for syntax errors on server at command line (if no bad side effects) hr is a good tag for reading debugging output sent to browser put Content-type right at top print to a public-writeable dir/file, print "got here" > "/tmp/cgi.debug" when in doubt, make your own echo > cgi.debug; chmod a+rw cgi.debug always view the source of the cgi output (could be html bug!) check /var/log/http/error_log (how? less error_log, shift-G, ctrl-B) DO write little t.awk scripts to test semantics gawk help: what is RS, FS? rsfs.awk what is an associative array? for (i in a) a[s] if (s in a) if (a[s]) string context of an index a[x,y] array.awk array2.awk what is the semantics of $i? read sets $0, $1...$NF, NF assignment to $i causes lazy evaluation of $0 with possible side effects on $(i+1), ...$NF, NF) what is gsub(r,s,t)? r=regexp s=subst t=target how to verify this quickly? man gawk /gsub\( man gawk | grep gsub my link to subman! translating special characters, +/space, %22/quote data = ENVIRON["QUERY_STRING"]; clean(data) func clean(x) { gsub("%22","\"",x) return x } parsing multi-field input: ok? saving state: in cookies: Set-Cookie: foo=val; foo2=val2; expires=date ENVIRON["HTTP_COOKIE"] spec.cgi much better in forms: input type=hidden name=foo value=bar even better with server-side files: make sure your file is chmod a+rw grepdat.cgi security: if you execute data using system or "com" | getline, YOU MUST (1) translate selective characters OR (2) handle ALL user data within '' grepcgi.cgi example/lab: saving data on the server side for search and dbase