tchrist@convex.com (Tom Christiansen) (11/22/90)
Here are two functionally equivalent versions of a program
to remove something from the sendmail queue. I notice that
the short version is MUCH harder to highball, but I find its
style coming out of my keyboard much more often.
What do you guys think of this?
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# rmmq.short
# rmmq.long
# This archive created: Wed Nov 21 14:53:27 1990
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'rmmq.short'" '(721 characters)'
if test -f 'rmmq.short'
then
echo shar: "will not over-write existing file 'rmmq.short'"
else
sed 's/^ X//' << \SHAR_EOF > 'rmmq.short'
X#!/bin/sh -- # summon the perl monster
X
Xeval "exec perl $0 $*"
X if $running_under_some_shell_and_would_really_prefer_to_use_perl;
X
X($ARGV[0] eq '-f') && ($force_flag++, shift);
X$MQUEUE = '/usr/spool/mqueue';
Xchdir $MQUEUE || die "can't cd to $MQUEUE: $!, bailing out";
X-w $MQUEUE || die "can't unlink from $MQUEUE, bailing out";
X
Xfor (@ARGV) {
X /^(\d+)$/ && ($_ = 'AA' . $1);
X /^AA/ || (warn "$0: ingoring funny mail id: $_\n", next);
X ((@files = <?f$_>)) || (warn "$0: no $_ mail request\n", next);
X $force_flag || grep(/^lf/,@files)
X || (warn "$0: request $_ in progress\n", next);
X for $file (@files) {
X print STDERR unlink($file)
X ? "$file\n"
X : "$0: can't unlink $file: $!\n";
X }
X}
SHAR_EOF
if test 721 -ne "`wc -c < 'rmmq.short'`"
then
echo shar: "error transmitting 'rmmq.short'" '(should have been 721 characters)'
fi
chmod 775 'rmmq.short'
fi
echo shar: "extracting 'rmmq.long'" '(822 characters)'
if test -f 'rmmq.long'
then
echo shar: "will not over-write existing file 'rmmq.long'"
else
sed 's/^ X//' << \SHAR_EOF > 'rmmq.long'
X#!/bin/sh -- # summon the perl monster
X
Xeval "exec perl $0 $@"
X if $running_under_some_shell_and_would_really_prefer_to_call_perl;
X
X$MQUEUE = '/usr/spool/mqueue';
X
Xif ($ARGV[0] eq '-f') {
X $force_flag++;
X shift;
X}
X
Xif (!chdir $MQUEUE) {
X die "can't cd to $MQUEUE: $!, bailing out";
X}
Xif (!-w $MQUEUE) {
X die "can't unlink from $MQUEUE, bailing out";
X}
X
Xfor (@ARGV) {
X if (/^(\d+)$/) {
X $_ = 'AA' . $1;
X }
X if (!/^AA/) {
X warn "$0: ingoring funny mail id: $_\n";
X next;
X }
X if (! (@files = <?f$_>)) {
X warn "$0: no $_ mail request\n";
X next;
X }
X if (!$force_flag && grep(/^lf/,@files)) {
X warn "$0: request $_ in progress\n";
X next;
X }
X for $file (@files) {
X if (unlink($file)) {
X print STDERR $file, "\n";
X } else {
X warn "$0: can't unlink $file: $!\n";
X }
X }
X}
SHAR_EOF
if test 822 -ne "`wc -c < 'rmmq.long'`"
then
echo shar: "error transmitting 'rmmq.long'" '(should have been 822 characters)'
fi
chmod 775 'rmmq.long'
fi
exit 0
# End of shell archivelwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (11/25/90)
In article <109125@convex.convex.com> tchrist@convex.com (Tom Christiansen) writes:
: Here are two functionally equivalent versions of a program
: to remove something from the sendmail queue. I notice that
: the short version is MUCH harder to highball, but I find its
: style coming out of my keyboard much more often.
:
: What do you guys think of this?
I think they're both lovely. But who cares what I think? :-)
Larry