3 # Copyright (c) 1996 Brian R. Gaeke
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # 3. All advertising materials mentioning features or use of this software
15 # must display the following acknowledgement:
16 # This product includes software developed by Brian R. Gaeke.
17 # 4. The name of the author, Brian R. Gaeke, may not be used to endorse
18 # or promote products derived from this software without specific
19 # prior written permission.
21 # THIS SOFTWARE IS PROVIDED BY BRIAN R. GAEKE ``AS IS'' AND ANY EXPRESS
22 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 # DISCLAIMED. IN NO EVENT SHALL BRIAN R. GAEKE BE LIABLE FOR ANY DIRECT,
25 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 # POSSIBILITY OF SUCH DAMAGE.
35 # This software is provided without support and without any obligation
36 # on the part of Brian R. Gaeke to assist in its use, correction,
37 # modification or enhancement.
39 #######################################################################
41 # this is atudel, version 2, by Brian R. Gaeke <brg@dgate.org>
46 $username = shift(@ARGV);
47 &usage unless $username;
51 print STDERR "atudel - remove all at jobs owned by a user\n";
52 print STDERR "usage: $0 [-v] username\n";
56 # odd. unless getpwnam($uname) doesn't seem to work for $uname eq "root" on
57 # my linux system. but this does.
58 die "user $username does not exist; stopping"
59 unless defined(getpwnam($username));
61 print "searching for at jobs owned by user $username ..." if $opt_v;
63 chdir "/var/spool/atjobs" ||
64 die "can't chdir to /var/spool/atjobs: $!\nstopping";
65 opendir(DIR,".") || die "can't opendir(/var/spool/atjobs): $!\nstopping";
66 @files = grep(!/^\./,grep(-f,readdir(DIR)));
71 $owner = (getpwuid((stat($x))[4]))[0];
72 push(@nuke_bait,$x) if $owner eq $username;
77 print "removed jobIDs: @{nuke_bait}.\n" if $opt_v;