home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- From: Bill.Campbell@celestial.com (Bill Campbell)
- Subject: v28i073: uureroute - Reroute HDB queued mail, Part01/01
- Message-ID: <1992Feb26.022837.27579@sparky.imd.sterling.com>
- X-Md4-Signature: 256a4af982c44cce4f3e1867694a06e3
- Date: Wed, 26 Feb 1992 02:28:37 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: Bill.Campbell@celestial.com (Bill Campbell)
- Posting-number: Volume 28, Issue 73
- Archive-name: uureroute/part01
- Environment: perl, HDB, smail2.5
-
- This is a Honey DanBer specific routine written in perl to reroute all
- mail queued up for a specific host. It needs to be run as "root" since
- uucp will not allow itself to remove others requests.
-
- Bill Campbell
- --------------------
- #! /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: uureroute
- # Wrapped by bill@camco1 on Tue Feb 11 07:44:10 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'uureroute' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'uureroute'\"
- else
- echo shar: Extracting \"'uureroute'\" \(3075 characters\)
- sed "s/^X//" >'uureroute' <<'END_OF_FILE'
- X:
- X#!/usr/local/bin/perl
- Xeval ' exec /usr/local/bin/perl $0 "$@" '
- X if $running_under_some_shell;
- X shift if(join("", @ARGV) eq ""); # Xenix Kludge
- X
- X# $Header: /u/usr/cvs/mail/uureroute,v 1.3 91/10/08 09:01:21 src Exp $
- X# $Date: 91/10/08 09:01:21 $
- X# @(#) $Id: uureroute,v 1.3 91/10/08 09:01:21 src Exp $
- X# $Log: uureroute,v $
- X# Revision 1.3 91/10/08 09:01:21 src
- X# ----------------------------------------------------------------------
- X# 1. Rewritten in perl
- X# 2. Add -v option for debugging.
- X#
- X# Revision 1.2 91/10/07 23:57:42 root
- X# 1. Fix mail program path.
- X# 2. Truncate directory name to 7 characters
- X#
- X# uureroute.sh host
- X#
- X# This is a Honey DanBer specific routine to reroute all mail queued up
- X# for a specific host. It needs to be run as "root" since uucp will not
- X# allow itself to remove others requests.
- X#
- X
- X( $progname = $0 ) =~ s!.*/!!; # save this very early
- X
- X$USAGE = "
- X# Reroute uucp mail
- X#
- X# Usage: $progname [-v] host [host...]
- X#
- X# Options Argument Description
- X# -v Verbose (doesn't execute /bin/sh)
- X#
- X";
- X
- Xsub usage {
- X die join("\n",@_) .
- X "\n$USAGE\n";
- X}
- X
- Xdo "getopts.pl";
- X
- X&usage("Invalid Option") unless do Getopts("vV");
- X
- X$verbose = ( $opt_v ? '-v' : () );
- X$suffix = ( $verbose ? '' : $$ );
- X
- X$\ = "\n"; # use newlines as separators.
- X
- X&usage("No system specified") if ($#ARGV < 0);
- X
- Xif(! $verbose ) {
- X open(SH, "| /bin/sh");
- X select(SH);
- X}
- Xprint "set -ex";
- Xwhile($system = shift) {
- X $directory = '/usr/spool/uucp/' . substr($system, 0, 7);
- X if( ! -d $directory ) {
- X print STDERR "$progname: nothing queued for $system";
- X next;
- X }
- X open(UUSTAT, "uustat -s $system|");
- X
- X line: while (<UUSTAT>) {
- X chop; # strip record separator
- X @Fields = split(' ', $_, 9999);
- X if (/^[a-z]/) {
- X $jobid = $Fields[0];
- X $datafile = $Fields[6];
- X }
- X else {
- X if ($Fields[4] ne 'rmail') {
- X next line;
- X }
- X $cmd = '/bin/smail -R'; # smail 2.5 rabid rerouter
- X splice(@Fields, 0, 5); # remove first 5 elements
- X while($addr = shift(@Fields)) {
- X $addr =~ s/@.*//; # drop domain part
- X $cmd .= " $system!$addr";
- X }
- X $cmd .= " < $directory/$datafile && uustat -k $jobid";
- X print $cmd;
- X }
- X }
- X close(UUSTAT);
- X}
- Xclose(SH) unless($verbose);
- X__END__
- X>From: mattc@ncr-sd.SanDiego.NCR.COM (Matt Costello)
- X>Newsgroups: comp.mail.uucp
- X>Subject: Re: Rerouting spooled UUCP mail (HDB+smail)
- X>Message-ID: <3038@ncr-sd.SanDiego.NCR.COM>
- X>Date: 27 Nov 90 19:04:24 GMT
- X>References: <17525@netcom.UUCP>
- X>Reply-To: mattc@ncr-sd.SanDiego.NCR.COM (Matt Costello)
- X>Organization: NCR Corporation, Rancho Bernardo
- X>Lines: 61
- X
- XHere is another shell script to reroute mail queued up in an outgoing
- XUUCP spool directory. It performs the same function as the script posted
- Xby Gordon Moffett <gam@netcom.UUCP> but it uses "uustat -s system" so
- Xit doesn't mess around in the bowels of UUCP. This makes it a whole lot
- Xsimpler and safer. Just change the shell procedure definition for mail()
- Xto match what your MTA needs.
- X
- X--
- XMatthew Costello <Matthew.Costello@SanDiego.NCR.COM>
- X+1 619 485 2926 uunet!ncrlnk!ncr-sd!mattc
- END_OF_FILE
- if test 3075 -ne `wc -c <'uureroute'`; then
- echo shar: \"'uureroute'\" unpacked with wrong size!
- fi
- chmod +x 'uureroute'
- # end of 'uureroute'
- fi
- echo shar: End of shell archive.
- exit 0
-
- Bill
- --
- INTERNET: bill@Celestial.COM Bill Campbell; Celestial Software
- UUCP: uunet!camco!bill 6641 East Mercer Way
- FAX: (206) 232-9186 Mercer Island, WA 98040; (206) 947-5591
-
-
- exit 0 # Just in case...
-