Nostradamus
Technical User
take a look at this script...
#!/usr/bin/ksh
ID=10000
id_user()
{
ID=`expr $ID + 1`
}
cat $1 |
while read line
do
USER=`echo $line | awk '{print $1}'`
INFO=`echo $line | awk '{print $2 " " $3}'`
echo mkuser id=$ID home=/home/$USER gecos="$INFO" $USER
id_user
done
This is (a simplyfied version) one of a couple of scripts I use to add users.
The input variable ($1) looks like this (as you might have guessed)
first column username
second column first name of user
third column last name of user.
As you can see I began the uid from 10 000 and for each new user (line in the input file) a add 1 number.
If the input file has 10 lines/users, then the last uid would be 10 010.
How do I add this number to the script?
The next time I run this script I want the ID variable to tell 10010 instead of 10000.
Hope you understand what I mean. /Sören
#!/usr/bin/ksh
ID=10000
id_user()
{
ID=`expr $ID + 1`
}
cat $1 |
while read line
do
USER=`echo $line | awk '{print $1}'`
INFO=`echo $line | awk '{print $2 " " $3}'`
echo mkuser id=$ID home=/home/$USER gecos="$INFO" $USER
id_user
done
This is (a simplyfied version) one of a couple of scripts I use to add users.
The input variable ($1) looks like this (as you might have guessed)
first column username
second column first name of user
third column last name of user.
As you can see I began the uid from 10 000 and for each new user (line in the input file) a add 1 number.
If the input file has 10 lines/users, then the last uid would be 10 010.
How do I add this number to the script?
The next time I run this script I want the ID variable to tell 10010 instead of 10000.
Hope you understand what I mean. /Sören