Re: A question about setup, with CERN httpd

Lance W. Bledsoe (lwb@cs.utexas.edu)
Wed, 10 May 1995 20:51:13 +0500


In a previous message Lisajoy posted:

Hello.

I think your script sounds interesting, but I'd need some instructions.
I'm not too clear about Perl, actually and honestly, I'm clueless. Pleas
be in touch.

-Lisajoy

Here is some html code which will run the script: (add this to your
home page or wherever...)

<dt> <a href="/cgi-bin/userpages.cgi"> Users with Home Pages </a>
<dd> Automatically generated index of User Home Pages</dd>

Theses two files need to be in your cgi-bin directory: (the permissions
*must* match these.)

1 -rwxr-xr-x 1 www www 141 Apr 24 14:08 userpages.cgi*
1 -rwxr-xr-x 1 www www 736 Apr 24 14:16 userpages.pl*

% pwd
/usr/local/src/httpd_1.3/cgi-bin

Here is the "userpages.cgi" shell script which will envoke the perl script
with the input from your systems passwd file: (save this code to a file
called "userpages.cgi" in the cgi-bin directory.)

#!/bin/sh
#
# Script to use userpages.pl to show the users with pages.

echo Content-type: text/html
echo

userpages.pl < /etc/passwd

echo

This is the "userpages.pl" code: (save this code to a file
called "userpages.cpl" in the cgi-bin directory.)

#!/usr/bin/perl
# ^^^^^^^^^^^^^ replace this with the path of perl executable

# The next several lines contain stuff which would normally be
# part of an html doc. (Whatever you like...)
# (NOTE: notice the placement of the "\" before embedded quotes,
# and the "\n" at the end of each line!)

print "<body BACKGROUND=\"/avalon/texture.gif\">\n";
print "<hr>\n";
print "<img alt=\"Avalon Enterprises Inc\" src=\"/avalon/aeilogo.gif\">\n";
print "<br>\n";
print "<hr>\n";
print "<br>\n";

# This is the "meat" of the code...

print "<HEAD>\n<title>Users with Home Pages</title>\n";
print "<h3>Users with Home Pages...</h3><p>\n";
print "<ul>\n";

while(<STDIN>) {
chop;
($login, $pw, $uid, $gid, $gcos, $home, $shell) = split(/:/);
($name, $office, $workph, $homeph) = split(/,/, $gcos);
if (-e "$home/public_html/index.html") {
print qq!<li><a href="/~$login/">!;
#print "$login ($name)</a>\n"; }
print "$name</a>\n"; }
}

# Place html code here (in print "...", of course) which you would want
# at the end of the page...

print "</ul>\n";

# End of file.

NOTE: you may want to change this script so that it's run once a day,
with the output going to a "userpages.html" file, if you have a large
number of users.

Hope this helps...

Lance

---=== lwb@AvalonCorp.com -- http://www.AvalonCorp.com/~lwb ===---
Avalon Enterprises, Inc. can develop or host your Web Page, Mailing List,
FTP Site or other Internet Service, on our quick server, at a minimal cost.
Please send email, or browse http://www.AvalonCorp.com for details.