On Tue, 10 Mar 1998, Douglas F. Elznic wrote:
[...]
>I remember seeing some on the net somewhere that would format the output
>to html so you could just point to it for a list of users home pages...

#!/bin/sh
p_catdir="/users/webpages/CATALOG"
p_pagesdir="public_html"
p_passwd="/etc/passwd"
p_srmconf="/etc/httpd/conf/srm.conf"
p_tmp="${TMP:-/tmp}"
p_unlisted=".unlisted"
p_urlpfx="http://www.patriot.net/users/"
umask 022
htaccess="`awk '$1 == \"AccessFileName\" {print $2}' \"$p_srmconf\"`"
awk -F: '$3 > 99 {print $1,$6,$5}' "$p_passwd" \
| sort \
| while read user home name
do
        set --
        pagesdir="$home/$p_pagesdir"
        if [ -d "$pagesdir" -a ! -e "$pagesdir/$p_unlisted" ]
        then
                if [ -r "$pagesdir/$htaccess" ]
                then
                        set -- `grep "DirectoryIndex" "$pagesdir/$htaccess"`
                        [ "$#" -gt 0 ] && shift
                fi
                if [ "$#" -eq 0 ]
                then
                        set -- `awk '$1 == "DirectoryIndex" {print}' "$p_srmconf
"`
                        shift
                fi
                for indexfile in "$@"
                do
                        if [ -r "$pagesdir/$indexfile" ]
                        then
                                echo "$user"
                                echo "$name" | cut -d, -f1
                                head -20 "$pagesdir/$indexfile" \
                                | grep -i '\<title>' \
                                | sed -n 's/^.*<[Tt][Ii][Tt][Ll][Ee]>//p' \
                                | sed 's/<\/[Tt][Ii][Tt][Ll][Ee]>.*$//' \
                                | (read title ; echo "$title")
                                echo "$p_urlpfx$user"
                                break
                        fi
                done
        fi
done \
| while read user
do
        read name
        read title
        read homepage
        group="`echo \"$user\" | cut -c1`"
        set -- $title
        [ $# -gt 9 ] && title="$1 $2 $3 $4 $5 $6 $7 $8 $9 ..."
        (       echo "<TR>"
                echo "<TD VALIGN=\"TOP\"><TT>$user</TT></TD>"
                echo "<TD>&nbsp;</TD>"
                echo "<TD>$name</TD>"
                echo "</TR>"
                echo "<TR>"
                echo "<TD>&nbsp;</TD>"
                echo "<TD>&nbsp;</TD>"
                echo "<TD>"
                [ -n "$title" ] && echo "<B>$title</B><BR>"
                echo "<SMALL><A HREF=\"$homepage\"><I>$homepage</I></A></SMALL>"
                echo "</TD>"
                echo "</TR>"
                echo "<TR>"
                echo "<TD>&nbsp;</TD>"
                echo "<TD>&nbsp;</TD>"
                echo "<TD>&nbsp;</TD>"
                echo "</TR>"
        ) >> "$p_catdir/$group.html.new"
done
for file in "$p_catdir"/*.new
do
        mv "$file" "`echo \"$file\" | sed 's/^\(.*\)\.new$/\1/'`"
done

-- 
    Steve Coile
 [EMAIL PROTECTED]


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to