Hello, everybody
First of all, I'd like to say thank you to all of you for the forum (admins, users...), it's a really valuable resource for a lot a people, including me.
I don't know if this is the right place where to ask this, my question is about my homework. If it's not, please, could an admin move it to its right place?... I'm a bit confused with an exercise, so if anybody can point me in the right direction (Or give me the answer) I'll be really gratefull:
Given a text file called
users.txt with this info inside:
Adam:2299:/home/store ;
John:8855:/home/accounts ;
Lisa:7744:/home/secondstore ;
Mary:6677:/home/address ;
The script should create an user using the first word of each line, the second word of each line will be used as password, and the third one as the home directory. The internal field separator is :
I can only use
awk or
shellscripting for the exercise. The teacher pointed that one of the posible solutions includes the SYSTEM command used inside AWK...but there are other solutions using only shellscripting.
I'm trying with (as root)
$ awk -F ':| ' '{ print("adduser --home", $3, $1"; echo", $2 " | passwd", $1) | "/bin/bash" }' users.txt
I don't know why it doesn't work
Any hint, any suggestion of other way of doing this or any help will be very apreciated
thanks