* Password maint. scripts
@ 1997-06-17 4:00 Eulogio Robles P.
1997-06-19 4:00 ` Bob Mazanec
0 siblings, 1 reply; 2+ messages in thread
From: Eulogio Robles P. @ 1997-06-17 4:00 UTC (permalink / raw)
Hi.
We recently buyed a couple of Alpha machines running OSF1 3.2.
(Most of our machines are Sun)
Our problem is, the interactive "adduser" is not
suitable for our applications. We urgently need the
non-interactive "useradd", "usermod" and "userdel" commands
used in Solaris.
Are there any utilities like these for OSF?
Thanks in advance
---------------------------------
Eulogio Robles P.
erobles@chilesat.net
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Password maint. scripts
1997-06-17 4:00 Password maint. scripts Eulogio Robles P.
@ 1997-06-19 4:00 ` Bob Mazanec
0 siblings, 0 replies; 2+ messages in thread
From: Bob Mazanec @ 1997-06-19 4:00 UTC (permalink / raw)
When writing install scripts in Perl for v3.2, I used something like
this:
#####################################################################
# Name: createNewUser
# Purpose: Add a user to the sytem
# Args: $user = login to add
# $passwd = password
# $uid = UID to add
# $group = Group name for $user
# $gcos = user info
# $shell = user's login shell
sub createNewUser {
local( $user, $passwd, $uid, $group, $gcos, $shell ) = @_;
open( ADDUSER, '| /usr/sbin/adduser > /dev/null 2>&1' )
|| &Die( 1, "cannot run adduser" );
print "\tAdding $user; press Control-D to continue...\n";
# adduser asks the following questions:
# what is the new user's login?
# what is the new user's UID?
# what is the new user's full name?
# what is the new user's login group?
# what other groups does the new user belong to?
# what is the base directory for the new user's home directory?
# do you want to edit the user's authentication file entry?
# <runs passwd, which reads /dev/tty directly -- this is why the
user
# must hit Ctrl-D>
print ADDUSER "$user\n"
. "$uid\n"
. "$gcos\n"
. "$group\n"
. "\n"
. "/home\n"
. "$shell\n"
. "n\n";
close ADDUSER;
# Having created the user's entry in /etc/passwd, use vipw
# to find the entry and hammer the password:
&runVipw( "/^${user}:", "s/:[^:]*:/:${passwd}:/" );
}
#####################################################################
# Name: runVipw
# Purpose: Run vipw and send a sequence of commands at it
# Args: @cmds = vipw commands
sub runVipw {
local( @cmds ) = @_;
die "runVipw requires a command list" unless @cmds;
local( $cmds ) = join( "\n", @cmds );
local( $ENV{ 'EDITOR' }) = '/usr/bin/ex';
local( $ENV{ 'TERM' }) = 'dumb';
open( VIPW, "| /usr/sbin/vipw > /dev/null 2>&1" )
|| &Die( 1, "cannot run vipw: $!" );
print VIPW "$cmds\n"; # caller's commands
print VIPW "x\n"; # exit
close VIPW;
}
Icky, but true ;-)
bob
--
Bob Mazanec mailto:mazanec@healthcare.com
Sr. Software Engineer 972/851-7033
Healthcare Communications, Inc. 970/249-8510
http://www.healthcare.com
Disclaimer: You think they _pay_ me to say this stuff?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-06-19 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-06-17 4:00 Password maint. scripts Eulogio Robles P.
1997-06-19 4:00 ` Bob Mazanec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox