Cover V02, I02
Article
Figure 1
Figure 10
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6
Figure 7
Figure 8
Figure 9
Listing 1
Listing 2
Listing 3
Listing 4
Table 1
Table 2
Table 3
Table 4

mar93.tar


Listing 4: uucancel.pl

1  #
2  # @(#) uucancel.pl - kill UUCP jobs by machine, user or all
3  # Copyright 1992, Chris Hare, UniLabs Research Group
4  # December 1992.  Born out of idea from Becca Thomas.
5  #
6  # This PERL script is based upon a shell program of the same name written
7  # for Rebecca Thomas of UNIX/World Magazine, to be published sometime in
8  # 1993.
9  #
10  # This script will kill UUCP jobs as selected by the user.  The options
11  # are
12  #       -a - to kill ALL UUCP jobs in the queue
13  #       -s - to kill UUCP jobs scheduled for this printer
14  #       -u - to kill UUCP jobs for this user
15  # NOTE : This script works ONLY with HDB uustat.  Version 2 uustat is not
16  #        supported.
17  #
18  # You must have the getopts.pl library file
19  require "getopts.pl";
20  #
21  # validte the user - we need to get the actual NAME of the EFFECTIVE ID
22  #
23  ( $id, @rest ) = getpwuid( $> );
24  $USAGE = "Usage : $0 [ -a ] [ -s system ] [ -u user ]";
25  #
26  # check for command line options and arguments.
27  #
28  &Getopts ('as:u:');
29  #
30  # Parse each of the options and define the command that will be used to get the
31  # desired information from uustat
32  #
33  if ( $opt_a )
34     {
35     $CMD = "uustat -a";
36     }
37  elsif ( $opt_s )
38     {
39     $CMD = "uustat -s $opt_s";
40     }
41  elsif ( $opt_u )
42     {
43     $CMD = "uustat -u $opt_u";
44     }
45  else
46     {
47     printf "$USAGE\n";
48     exit (2);
49     }
50
51  #
52  # CMD is the command named above, which is determined by the command line
53  # flag.  The ^[^        ] is a space and tab between the '[]'.  This is
54  # set to match any character at the beginning of the line EXCEPT a space or
55  # a tab.
56  #
57  printf "cmd=:$CMD:\n";
58  open( cmd_pipe, "$CMD | grep '^[^       ]' |" );
59
60  while (<cmd_pipe>)
61     {
62     # Cancel the UUCP jobs, and report the job numbers as they are cancelled
63     chop;
64     y/ / /s;
65     ( $job_id, $date, $dir, $machine, $user, @text ) = split(/ /);
66     printf "date=$date dir=$dir mach=$machine user=$user\n";
67     printf "Cancelling UUCP request id $job_id($user) ...\n\t";
68     if ( $id eq $user || $id eq root )
69        {
70        system( "uustat -k$job_id" );
71            }
72     else
73            {
74        printf "request denied : not owner or root\n";
75            }
76     }
77  exit (0);