16 August 2025

CGI

System: Slackware Linux (version 15.0)
CPUs: Intel(R) Core(TM) i5-3230M CPU @2.60GHz
GPU: Mesa DRI Intel(R) HD Graphics 4000

A trivial CGI example using a shell script.

bash-5.1$ mkdir -p ~/public_html/cgi-bin
bash-5.1$ cat <<EOF > ~/public_html/cgi-bin/brazil
> #!/bin/sh
> echo -e "Content-Type: text/plain\n\n"; TZ="America/Bahia" date
> EOF
bash-5.1$ chmod 744 ~/public_html/cgi-bin/brazil
bash-5.1$ python3 -m http.server -d ~/public_html --cgi &
[1] 1640
bash-5.1$ Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

bash-5.1$ w3m -dump http://localhost:8000/cgi-bin/brazil
127.0.0.1 - - [15/Aug/2025 21:20:28] "GET /cgi-bin/brazil HTTP/1.0" 200 -

Sun Aug 15 16:20:28 -03 2025
bash-5.1$ kill 1640
bash-5.1$



The global directory for cgi files.

root@darkstar:~# ls /var/www/cgi-bin
printenv  printenv.vbs  printenv.wsf  test-cgi
root@darkstar:~#