February 2006
Intermediate to advanced
304 pages
6h 16m
English
One of your students has violated the no hacking policy repeatedly. So you're going to give him a time-out for a few weeks and turn off his account.
Note:
This script is system dependent. Don't run it on your system until you've inspected it and know it fits your operation.
1 #!/usr/bin/perl 2 use strict; 3 use warnings; 4 5 if ($#ARGV != 0) { 6 print STDERR "Usage is $0 <account>\n"; 7 } 8 9 my $user = $ARGV[0]; 10 11 # Get login information 12 my $uid = getpwnam($user); 13 if (not defined($uid)) { 14 print "$user does not exist.\n"; 15 exit (8); 16 } 17 18 system("passwd -l $user"); 19 my @who = 'who'; 20 @who = grep /^$user\s/, @who; 21 foreach my $cur_who (@who) { 22 my @words = split /\s+/, $cur_who; 23 ...Read now
Unlock full access