You could avoid searching the passwd file by just using the unix command as
you said, and to do this within perl:

system("userdel username -r");

or if you only want to remove some line from some file:

# read the file
open (FILE, "</etc/passwd");
@contents=<FILE>;
close (FILE);

#write the file back, except for the one line
open (FILE,">/etc/passwd");
foreach (@contents){
        if (/dont write this line/){
                next;
        }
}
close (FILE);

There's a million ways to do it, but let me know if there is a more
efficient way, which there always is....


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 07, 2001 11:02 AM
To: [EMAIL PROTECTED]
Subject: removing a line!!!


hi there,
i am just a 2 days perl beginner and trying to do something like this:
searching a pattern in a file line by line (/etc/passwd infact),and if it
matches,deleting that line...
i just made the matching line properly,but don't know how to delete that
matching properly...
in fact, i am trying to delete the entry of a user in /etc/passwd to remove
it from the  system...this is something like "pass username",which searches
for username and when matches deletes...(hey i know there are commands to
do this by unix, i am just trying to learn)..
any help??
regards...



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to