I'm still struggling to devise a simple way to add large numbers of user accounts using csv files or similar. The users already exist on an Acorn Level 4 server and I want to move the users and passwords, transparently to a Linux server. I have no problem exporting the csv file but...... Anyone help with these points 1) useradd in RedHat does not appear to understand the -p option and it is not mentioned in the man pages. Does suse recognise this option and as a result allow a single line entry for a user and their password? 2) If I type useradd as root I get an error - "bash: useradd: command not found" but $PATH reports /usr/sbin as part of the path and this is where useradd is located. What am I missing? 3) Can anyone recommend a good source of information on writing shell scripts - I might then be able to fiddle around with the passwd command. Dave Williams
3) Can anyone recommend a good source of information on writing shell scripts - I might then be able to fiddle around with the passwd command.
does the csv file just have a list of comma seperated usernames, or does it contain any other information such as Full name, password etc.? a shell/perl script could be easily devised to make use of such a file. eg. if the file contains just usernames like matthew,,james,harry,william then something like "cat users.csv | tr "," "\n" | xargs -i /usr/sbin/useradd {}" to start with you might want to set their usernames to their passwds (uh!) "cat users.csv | tr "," "\n" | xargs -i setpasswd {}" where the script setpasswd = "printf "$1\n" | passwd --stdin -f $1" this cmd line can be made a lot more complicated as other values such as fullname, password are present in the file. hope this is a start!
On 30 May, Richard Naylor <ranaylor@ntlworld.com> wrote:
3) Can anyone recommend a good source of information on writing shell scripts - I might then be able to fiddle around with the passwd command.
does the csv file just have a list of comma seperated usernames, or does it contain any other information such as Full name, password etc.?
The csv file can contain anything which is appropriate - it's easy to adjust.
eg. if the file contains just usernames like matthew,,james,harry,william then something like "cat users.csv | tr "," "\n" | xargs -i /usr/sbin/useradd {}"
Tried this and it works - thanks. I've tried to understand the syntax and I thnk I understand most of it.
to start with you might want to set their usernames to their passwds (uh!) "cat users.csv | tr "," "\n" | xargs -i setpasswd {}" where the script setpasswd = "printf "$1\n" | passwd --stdin -f $1"
Tried this but it generates an error "passwd: invalid option -- -" I've tried adjusting various bits without success which isn't suprising because I don't understand the way this works. The normal passwd command follows this sequence passwd albert<enter> Then get text message and prompt for new password. type password<enter> Then get prompt to retype password type password<enter> How does the setpasswd script duplicate this sequence?
hope this is a start!
This has been really useful. I am *very* grateful. Dave Williams
to start with you might want to set their usernames to their passwds (uh!) "cat users.csv | tr "," "\n" | xargs -i setpasswd {}" where the script setpasswd = "printf "$1\n" | passwd --stdin -f $1"
Tried this but it generates an error "passwd: invalid option -- -" I've tried adjusting various bits without success which isn't suprising
i think that there is a good way to set passwds using the mkpasswd program. i had forgotten about it when i first posted. sorry! try this cat users.csv | tr "," "\n" | xargs -i /usr/bin/mkpasswd {} | tr "\n" "," > passwords this will set a good password for each user in the csv file. each password will be stored in a file named passwords. each password in the list represents the password for the respective user in the users.csv file. i'm sure that u can merge the file nicely so that you have a good record of all passwords. i would think a perl script might be best for this merging. e.g. #!/usr/bin/perl open USERS, "users.csv"; open PASSWDS, "passwords"; open MERGED, ">userandpass"; $/ = ","; while ($userid = <USERS>) { chomp $userid; print MERGED "$userid => "; $passwd = <PASSWDS>; chomp $passwd; print MERGED "$passwd\n"; } close USERS; close PASSWDS; close MERGED;
On 31 May, Richard Naylor <ranaylor@ntlworld.com> wrote:
i think that there is a good way to set passwds using the mkpasswd program. i had forgotten about it when i first posted. sorry!
try this
cat users.csv | tr "," "\n" | xargs -i /usr/bin/mkpasswd {} | tr "\n" "," > passwords
Sorry for the delay in replying. Finally got round to trying this but all I get is an error /usr/sbin/mkpasswd: no DBM database on system - no action performed I have no idea what a DBM database is - any ideas?
participants (2)
-
Dave Williams
-
Richard Naylor