Simon Bryan wrote:

I have been trying to find an adduser script that will read it's input from
a file. I used to have one but it has gone MIA.
I need to be able to set username, gid, home directory and shell.
How about just reformatting the file suitably for "useradd"?

awk -f reformat.awk < names.txt | sh

where reformat.awk is a variant of

 BEGIN { FS=":" }
 { full_name = $1
   user_id = $2
   password = $3
   printf "useradd -p '%s' -c '%s' '%s'\n",
          password,
          full_name,
          user_id
 }

--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to