[comp.mail.misc] anyone got perl for aliases --> mail.aliases?

chip@tct.com (Chip Salzenberg) (04/01/91)

No...  but I do have a translator from the Sendmail/Smail "aliases"
format to the Elm "aliases.text" format.  Modifying this translator
for other output formats should be very easy.

The "s2e" script is below, along with the "ga" wrapper.

Shar and enjoy.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  ga s2e
# Wrapped by chip@count on Mon Apr  1 10:25:24 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'ga' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ga'\"
else
echo shar: Extracting \"'ga'\" \(267 characters\)
sed "s/^X//" >'ga' <<'END_OF_FILE'
X: ga
X# Set Elm global aliases from Smail aliases.
X
XE=aliases.text
X
XL=/usr/smail/lib
XS=$L/aliases
X##test -f $L/aliases.local && S="$L/aliases.local $S"
X
Xif ./s2e $S >$E
Xthen
X	/u/local/bin/newalias -g
X	chgrp bin aliases.*
X	chown bin aliases.*
Xelse
X	rm -f $E
X	exit 1
Xfi
END_OF_FILE
if test 267 -ne `wc -c <'ga'`; then
    echo shar: \"'ga'\" unpacked with wrong size!
fi
chmod +x 'ga'
# end of 'ga'
fi
if test -f 's2e' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'s2e'\"
else
echo shar: Extracting \"'s2e'\" \(775 characters\)
sed "s/^X//" >'s2e' <<'END_OF_FILE'
Xeval 'exec /bin/perl -S $0 ${1+"$@"}'
X	if 0;
X
X# s2e
X# Smail to Elm alias file translator.
X
X## $domain = "uucp";
X$domain = "";
X
Xwhile (<>) {
X	chop;
X	s/\s*#.*//;
X	next if /^$/;
X	next unless ($alias, $rest) = /^\s*(\S+)\s*:\s*(.*)$/;
X	unless (($list, $comment) = ($rest =~ /(.*)\((.*)\)/)) {
X		$list = $rest;
X		$comment = "";
X	}
X	$list =~ s/\s//g;
X
X	## print stderr "$alias: $list ($comment)\n";
X
X	$LIST{$alias} = $list;
X	$COMMENT{$alias} = $comment;
X}
X
Xfor $a (sort keys(LIST)) {
X	$list = $a;
X	$comment = "";
X	while (defined($LIST{$list})) {
X		$comment = $COMMENT{$list} unless $comment;
X		$list = $LIST{$list};
X	}
X
X	if ($domain) {
X		@X = split(',', $list);
X		grep(s/@([^\.]+)$/@\1.$domain/ || 1, @X);
X		$list = join(',', @X);
X	}
X
X	print "$a = $comment = $list\n";
X}
X
Xexit(0);
END_OF_FILE
if test 775 -ne `wc -c <'s2e'`; then
    echo shar: \"'s2e'\" unpacked with wrong size!
fi
chmod +x 's2e'
# end of 's2e'
fi
echo shar: End of shell archive.
exit 0
-- 
Chip Salzenberg at Teltronics/TCT     <chip@tct.com>, <uunet!pdn!tct!chip>
   "All this is conjecture of course, since I *only* post in the nude.
    Nothing comes between me and my t.b.  Nothing."   -- Bill Coderre