justmy2cents |
05-25-2017 02:30 PM |
Script to create multiple users, not working..
Hello ladies and gents, I have this script that im not quite sure why it's not working. Any help would be appreciated, Thank You.
Code:
#!/bin/bash
for (( i=0; i<=500; i++ ))
do
useradd next$1
< /dev/urandom tr -dc A-Za-z0-9_|head -c8 > /tmp/passwd.txt
cat /tmp/passwd.txt|passwd --stdin user$i
done
rm -rf /tmp/passwd.txt
Basically this script makes users with names next0, next1, next3 and so on up till 500.. The /dev/urandom part generates a random password and directs the output to /tmp/passwd.txt, but that goes on indefinitely, so head -c8 is used to specify the password length to be 8 characters (the -c8 does this)... The error that occurs is that it says --stdin is an unrecognized option.. My code succeeds in creating the users but their passwords fail to get created.
|