cgi example using awk:
server-side file.csv...
# name, email, address, region
Moe,
[email protected],123 Maple St,Anywhere USA Larry,
[email protected],Hofgartenstr 8,80539 Munchen
Curly,
[email protected],1001 Ventura Blvd,Los Angeles CA
-----------------------------------------------------------
server-side cgi script...
#!/bin/sh
awk '
BEGIN {
FS = ","
print "Content-type: text/plain"
print ""
split(ENVIRON["QUERY_STRING"], a, "&")
b = a[1]
sub(/^name=/, "", b)
}
{
if (tolower($1) ~ tolower(b)) {
print $1 " <" $2 ">"
for(x = 3; x <= NF; x++) print $x
++e
}
}
END {if(!e) print b " not listed..."}' /var/www/cgi-bin/buddy.csv
# eof
browser query:
http://192.168.56.117/cgi-bin/buddy.awk?name=moe
output...
Moe <
[email protected]>
123 Maple St
Anywhere USA
-----------------------------------------------------------
unix shell script using wget...
#!/bin/sh
IPA="192.168.56.117"
[ $# -eq 0 ] && {
cat <<ERR
error no argument specified...
usage example: buddy.sh curly
ERR
exit 1
}
wget -qO-
http://$IPA/cgi-bin/buddy.awk?name="$*"
# eof
command line query: buddy.sh larry
output...
Larry <
[email protected]>
Hofgartenstr 8
80539 Munchen
-----------------------------------------------------------
win cmd script using wget...
@echo off
set IPA="192.168.56.117"
if "%~1"=="" goto end
wget -qO-
http://%IPA%/cgi-bin/buddy.awk?name="%*"
exit /b 0
:end
(
echo error no argument specified...
echo usage example: buddy.cmd curly
)
:: eof
command line query: buddy.cmd curly
output...
Curly <
[email protected]>
1001 Ventura Blvd
Los Angeles CA
--
:wq
Mike Sanders
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)