develooper Front page | perl.beginners | Postings from May 2008

deleting a user name from a file

Thread Next
From:
Lokeey
Date:
May 9, 2008 09:44
Subject:
deleting a user name from a file
I'm writing this script to remove users from a file, the sudoers file, to be
more specific.

Here is what I have so far, not sure where to go from here.

*#!/usr/bin/perl -w

# this script removes a user from sudoers file

my $sites = $ARGV[0];
my $user = $ARGV[1];

for my $site ($#ARGV[1]){
  open FILE, "$_/local/etc/sudoers" or die "cannot open sudoers for $sites:
$!";

print "Enter username you wish to remove from $sites sudoers.\n";

  while (<FILE>) {s/$_//}
  close FILE;
}*


-- 
"It's not what people call you, it's what you answer to."


Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About