============================= Building a CGI Script on Unix ============================= -IAN! idallen@ncf.ca A CGI script is a dynamically-generated web page. The content of the page is produced not from a static text file, but rather from the output of commands running on the web server. The content of the web page changes as the output of the commands change. You can build a dynamic web page using Unix commands, without knowing any CGI scripting. Here's how. 1) Create a public_html directory in your HOME directory on ACADAIX. Make sure it has read and execute permissions for everyone. Make sure your ACADAIX HOME directory has execute permissions for everyone. 2) Put these next lines of text into the file public_html/who.cgi. The lines must start at the left margin. No indenting! No blank line! (If you haven't learned any VI yet, start now!) #!/bin/sh # This is a CGI script. export PATH=/bin:/usr/bin umask 022 echo "Content-Type: text/plain" echo "" who Display and word-count the file to verify that it looks EXACTLY as above. $ wc public_html/who.cgi 7 17 114 public_html/who.cgi You can also checksum the file to make sure it is the same as mine: $ sum public_html/who.cgi 61714 1 public_html/who.cgi 3) Turn on execute permissions (for you, group, and other) on the new who.cgi file. Next, test the executable file at the shell prompt first: $ cd public_html $ ./who.cgi | more Verify that the first line of output is "Content-Type: text/plain". The second line must be blank. The rest of the output should be the output of "who". Fix any errors you find. 4) Enter a URL in this form into Netscape: http://acadaix/~abcd0001 Replace abcd0001 with your acadaix userid. If you get a permission denied error, add "x" permissions to your HOME directory to allow others to search it. Make sure the public_html directory has both "r" *and* "x" permissions for everyone. You should now see the name of your who.cgi script. Click on it to make the script execute. If you get a permission denied error, fix the permissions to allow others to read and execute the file. 5) Modify the end of the script to include any other Unix commands you might know, e.g. date, echo, ls, write, etc. Test the script from the shell prompt first, then finally try it from Netscape.