Subject: Script needed...

From: Ed Greshko <[email-masked]>
Date: Wed, 16 Mar 1994 11:11:46 +0800 (TPE)

Hello,

	Does anyone have a script to convert elm aliases into pine
aliases?

Edward M. Greshko			Control Data Taiwan
Voice: +886-2-715-2222 x287		6/F, 131 Nanking East Road, Section 3
FAX  : +886-2-712-9197			Taipei, Taiwan R.O.C

---

From: "Michael J. Corrigan" <[email-masked]>
Date: Tue, 15 Mar 1994 22:59:11 -0800

> FAX  : +886-2-712-9197			Taipei, Taiwan R.O.C
For simple cases:
#!/bin/sh
#
# A filter to convert personal mail aliases in a ~/.elm/aliases.text file into
# pine address book format. Modelled after brk2pine.sh
#
# Usage: elm2pine 
#
#
if [ ! -r $HOME/.elm/aliases.text ] 
then
	echo "You have no elm aliases to convert. Nothing needs to be done."
	exit
fi
if [ -f $HOME/.addressbook ]
then
	echo "Converting aliases from elm to existing .addressbook"
	sed 's/[ ]*=[ ]*/	/g' ${*-$HOME/.elm/aliases.text} >> .addressbook
else
	echo "Creating .addressbook and converting elm aliases"
	sed 's/[ ]*=[ ]*/	/g' ${*-$HOME/.elm/aliases.text} > .addressbook
fi
echo "Done. Your elm aliases are now also pine aliases."

---

From: "Stephen F. Day [Med Ctr Comp Svcs]" <[email-masked]>
Date: Wed, 16 Mar 1994 08:36:32 -0600 (MDT)

Subject: Script needed...
From: Ed Greshko <[email-masked]>
To: [email-masked]
Date: Wed, 16 Mar 1994 11:11:46 +0800 (TPE)

Hello,

#! /usr/local/gnu/bin/perl
# ---------------------------------------------------------------------
# 
# File:     e2p_addr.pl
# Title:    Converts elm aliases.text to pine's .addressbook
#
# Use:      perl e2p_addr.pl 
#           -or-
#           e2p_addr.pl 
#
# Created:   9-OCT-1992, Stephen F. Day
# Updated:  12-OCT-1992, SDAY -- added write_distrib_lines and 
#                                remove_CIRT_Unix_host subroutines
#           12-OCT-1992, SDAY -- bug fixes and finishing comments
#
# Purpose:  Converts the file ~/.elm/aliases.text to pine's .addressbook.
#           If .addressbook already exists, then the new addresses are
#           appended to it.
#
# ----------------------------------------------------------------------

# location of elm and pine alias files
$elm_addr = $ENV{'HOME'}.'/.elm/aliases.text';
$pine_addr = $ENV{'HOME'}.'/.addressbook';

# flag for continuation of distribution lists
$cont = 0;

open (ELMADDR, "< $elm_addr") || die "Couldn't find $elm_addr: $!\n";
open (PINEADDR, ">> $pine_addr") || die "Couldn't open $pine_addr: $!\n";

while ($line = <ELMADDR>) {
  chop $line;                    # remove \n at end of line

  # check to see if line defines an alias (it will has a '=' if it does)
  if ($line =~ /=/) {
    ($nicknames, $description, $email_addr) = split(/=/, $line);
    &strip_white_ends(*description);

    # if multiple aliases, make 2nd..nth ones point to the first alias
    @nicknames = split(',',$nicknames);
    $first_alias = shift(@nicknames);
    foreach $alias (@nicknames) {
      &strip_white_ends(*alias);
      print PINEADDR "$alias\t$description\t$first_alias\n";
    }

    print PINEADDR "$first_alias\t$description\t";

    # a comma indicates alias is a distribution list
    if ($email_addr =~ /,/) {
      print PINEADDR "(\n";
      &write_distrib_line(*email_addr);

    # no comma means not a distribution list -- just write e-mail address
    } else {
      &strip_white_ends(*email_addr);
      &remove_CIRT_Unix_host(*email_addr);
      print PINEADDR "$email_addr\n";
    }

  # no '=' means that this line is a continuation of the previous one
  } else {
    &write_distrib_line(*line);
  }
}

# close the files being read and written to
close ELMADDR;
close PINEADDR;

# subroutine that strips leading/trailing whitespace
sub strip_white_ends {
  local(*somestring) = @_;
  $somestring =~ s/^[ \t\r\n]+//;
  $somestring =~ s/[ \t\r\n]+$//;
}

# subroutine that writes e-mail address for distribution lists
sub write_distrib_line {
  local(*dist_addr) = @_;
  # a trailing comma means this list will be continued on next line
  if ($dist_addr =~ /,[ \t\n\r]*$/) {
    $cont = 1;
  } else {
    $cont = 0;
  }

  # write each e-mail address on a separate line (just for clarity)    
  @dist_addr = split(',',$dist_addr);
  foreach $addr (@dist_addr) {
    &strip_white_ends(*addr);
    print PINEADDR "          $addr,\n"; 
  }

  # if last line of distribution list, write closing parenthesis
  print PINEADDR "          )\n" if (!$cont);
}