Operating System - HP-UX
1837257 Members
2411 Online
110115 Solutions
New Discussion

Re: useradd.sam -m option not working

 
Phil Davey
Occasional Advisor

useradd.sam -m option not working

I have written a script to remotely add users to multiple servers using useradd.sam to enter a password as well, but the -m option is not working to create the user directory.

I have a workaround to create the directory first, but am confused why it does not work

Here is the command I am running (after substitution).
ssh server "/usr/sam/lbin/useradd.sam -g support -c "Test User" -m -d "/home/testuser" -p `echo "PasswordM4"| tr -A " " "" | /usr/lbin/makekey` testuser"

I also have the same problem with remsh (where available), or running the command locally directly on the machine.
6 REPLIES 6
Peter Godron
Honored Contributor

Re: useradd.sam -m option not working

Phil,
earlier threads, such as:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=86995

seem to indicate that useradd.sam can be used with an EXISTING user, but not for things like directory creation.
Ananda Matthur
New Member

Re: useradd.sam -m option not working

Hi Phil,
Which operating system version are you running? The -m option is working for me on an 11.31 system (11iv3). Here is my output:

1131pa04# ./useradd.sam -m -d /home/ananda ananda
1131pa04# ls /home
ananda
1131pa04# ls /home/ananda
.cshrc .exrc .login .profile
1131pa04# tail /etc/passwd
tui_team:bbJKlmU2u2U.s:119:20::/home/tui_team:/sbin/sh
raji_ug:hAYJRjuaavmI.:120:20::/home/raji_ug:/sbin/sh
xyxy:0Dv7.Zkn51FnE:121:20::/home/xyxy:/sbin/sh
koko:.beKtfhF9woxo:122:20::/home/koko:/sbin/sh
hyhy:ne8O2HLI.ASeE:123:20::/home/hyhy:/sbin/sh
hyhy2:WgHt1s/pCjAPI:124:20::/home/hyhy2:/sbin/sh
uuuuuop:okxnt6s3ixtpc:125:20::/home/uuuuuop:/sbin/sh
asdf:YC2wrNzebNS4M:118:20::/home/asdf:/sbin/sh
lplpl:.C/MxsiJsZ5wE:126:20::/home/lplpl:/sbin/sh
ananda:*:109:20::/home/ananda:/sbin/sh
1131pa04#

James George_1
Trusted Contributor

Re: useradd.sam -m option not working

Hi

I think its a small syntax issue ..

-m -d should not be given together .. here is the regular useradd command that I would give ..

# useradd -g 20 -G 102 -d /home/ldbajxg -s /usr/bin/ksh -c " Name xyz " -m ldbajxg

( -m will create the home directory)
Try in this order ... -d first and then -m ..in this case .. -d "/home/testuser" -m ...

Good luck
James George

forum is for techies .....heaven is for those who are born again !!
Phil Davey
Occasional Advisor

Re: useradd.sam -m option not working

Thanks for the responses, unfortunately the problem is not resolved.

Ananda: O/s HP-UX 11.11.

James: Changing the order of the options does not seem to work either. I have tried several combinations, including leaving off the -d option so it should use the default location.
Robert-Jan Goossens
Honored Contributor

Re: useradd.sam -m option not working

ssh server "/usr/sam/lbin/useradd.sam -g support -c "Test User" -m -d /home/testuser -p `echo "PasswordM4"| tr -A " " "" | /usr/lbin/makekey` testuser"

Try removing the double quotes from -d option and maybe you need to supply the -u (uid) option.

Regards,
Robert-Jan

Phil Davey
Occasional Advisor

Re: useradd.sam -m option not working

Thanks for the suggestion, but I have already tried removing the quotes (and even removing the -d option since I only want the default home directory anyway), and I let the server decide the uid, since the uid will vary across servers.