I am working on a cgi script (written using sh) that will output qmail
aliases.  I need to create some way to filter the output so that certain
things are not displayed. It needs to eliminate output for:
* aliases that go to /dev/null
* aliases where the name of the alias is contained in the first line of the
file
	(eg-  $i="john" in the script below, and the file's first line is "johna")
* aliases where the first line of the file is contained in the filename
	(eg- $i="johnb" in the script below and the first line of the file is
"john")

I can do the first part no problem, but the other 2 I am not sure the best
way to do. For the name matching, it should also match the start of string
(ie /^john/ not /john/) and only the first line. I know this is most likely
very easy in other languages such as Perl or PHP, but these are not
installed, as this is just a mail server (it doesn't even have a web server,
we are using rsh to do this)

Does anyone have any ideas?

The main part of the script looks like this:

echo "<TABLE BORDER=1>"
for i in $aliases;
do
	if [ -n "$nofilter" ];
	then
		echo "<TR VALIGN=top><TD>$i</TD>"
		echo "<TD><PRE>"
		cat /var/qmail/alias/.qmail-$i
		echo "</PRE></TD></TR>"
	else
		if [ -z "`grep /dev/null /var/qmail/alias/.qmail-$i`" ]; then
			echo "<TR VALIGN=top><TD>$i</TD>"
			echo "<TD><PRE>"
			cat /var/qmail/alias/.qmail-$i
			echo "</PRE></TD></TR>"
		fi
	fi
done
echo "</TABLE>"

--
Jay
Publishing Business Systems
651-634-9217