Linux - Scripting User Creation

Jasonh100

Senior member
Apr 21, 2001
200
0
0
I need to know how I can create users from either a Perl script or a batch script.

the script would need to take the username and password from command line parameters and use useradd (unless there is a more technical way that would be easier) and smbpasswd (unless there is a more technical way that would be easier) to add a user to the linux system and to the samba system.

thanks!
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Do you know anything about scripting or perl? This would be simple to do in bash+expect or perl.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
#!/usr/bin/perl
`adduser $ARGV[0]`;
`passwd $ARGV[0] $ARGV[1]`;

That passwd command wont work, but I couldn't think of a way to update a password on one line. you get the idea, though.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
If you're just gonna use `` to execute add user and passwd why not just use a shell script?

Anyway you need to interact with passwd and smbpasswd, so expect or perl's redirecting open() would be necessary.