February 2006
Intermediate to advanced
304 pages
6h 16m
English
Your user has been disabled. Now get rid of him.
Warning:
This script can destroy data and depends not only on the operating system you are using, but also on your system administration policies. Please inspect it before use.
1 #!/usr/bin/perl 2 use strict; 3 use warnings; 4 use Fcntl ':flock'; # import LOCK_* constants 5 6 if ($#ARGV != 0) { 7 print STDERR "Usage is $0 <user>\n"; 8 exit (8); 9 } 10 11 my $user = $ARGV[0]; 12 13 sub edit_file($) 14 { 15 my $file = shift; 16 17 open IN_FILE, "<$file" or 18 die("Could not open $file for input"); 19 20 open OUT_FILE, ">$file.new" or 21 die("Could not open $file.new for output"); 22 23 while (1) { 24 my $line = <IN_FILE>; 25 if (not defined($line)) { 26 last; 27 } ...Read now
Unlock full access