Creating Gateways to UNIX Commands

One of the most common uses of shell scripts in CGI programming is to create Web gateways to UNIX commands. Rather than logging into a server using Telnet or SSH every time you want to find out some of the vital statistics for the machine, it might be easier just to write a CGI script that executes the commands you’re interested in and prints the results to an HTML document. Shell scripts consist mostly of UNIX commands, so using shell scripts to create these kinds of CGI programs is an obvious choice.

Let’s look at a script that executes several commands that are of use to system administrators and that provide a general picture of how the computer is doing. You’ll execute the uptime command to see how busy ...

Get Sams Teach Yourself CGI in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.