UNIX / Notes on making a shell CGI

Home | UNIX | Practical

Notes on making a shell CGI


To make a simple CGI printing client's IP address and hostname,
#!/bin/sh
cat << EOF
Content-type: text/plain

Your IP is $REMOTE_ADDR
and resolves to `host $REMOTE_ADDR`
EOF

To make a CGI printing some random passwords (pwgen needs to be installed),
#!/bin/sh
PATH=$PATH:/usr/pkg/bin
cat << EOF
Content-type: text/plain

EOF
echo -n "Random password: "
/usr/pkg/bin/pwgen -A -n
echo "Press F5 to refresh"
Note. the PATH here is for NetBSD.



Sat Nov 8 12:19:47 CET 2008
       © 2008 Pierre-Philipp Braun