Skip to Main Content
Wicked Cool Perl Scripts
book

Wicked Cool Perl Scripts

by Steve Oualline
February 2006
Intermediate to advanced content levelIntermediate to advanced
304 pages
6h 16m
English
No Starch Press
Content preview from Wicked Cool Perl Scripts

#24 Adding a User

There are lots of programs out there to add a user to a Unix or Linux system. Just fill in the blanks, click the Add button, and you're done. Why write a script to do it?

If you're adding one user, this script is useless. But if you have to add several thousand, it can be very useful as the back end to a much larger batch system. (For example, if you were working at a university, you could connect this script to one that reads a list of incoming students and creates accounts for them automatically.)

The Code

 1 #!/usr/bin/perl 2 use strict; 3 use warnings; 4 use Fcntl ':flock'; # import LOCK_* constants 5 6 # The file we are going to change 7 my $pw_file = "/etc/passwd"; 8 my $group_file = "/etc/group"; 9 my $shadow_file = ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl Debugged

Perl Debugged

Peter Scott, Ed Wright
Perl & LWP

Perl & LWP

Sean M. Burke
Pro Perl

Pro Perl

Peter Wainwright

Publisher Resources

ISBN: 1593270623Catalog PageErrata