Adduser Script Not Working .. Can Any 1 Tell Me Why?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
while (( i=001 ; i<= 400 = user ;a= 3001 ; a <= 3400 ; = UID))
do
echo useradd -p "123" -m -f 28 -G 9999 -u $a user{$i}
Done
2 things.
1. You should make all posts on the same subject in the same thread
2. No offense, but this script is so horribly wrong, it's kindof difficult to tell you what exactly is wrong... it's all wrong. Take a look here: http://tldp.org/LDP/abs/html/loops1.html#EX25
edit: ok, to give you a little pointer, take a look at this:
Code:
#!/bin/bash
i=1
a=3001
while [ "$i" -lt 400 ]
do
echo $i $a
i=$(($i+1))
a=$(($a+1))
done
exit
I see from your other post that this is homework. You probably should post back after looking at the link BrianK gave you
yes it is homework and apparently no one in my entire class knows how to do it. Right now im the only one in class sitting back to try an figure it out as I have to submit it tommorow.I read all the posts but have no clue how to write this script and have been tryin to google for the last 2 hours. The prof said its like a 6-9 line script an I think that isnt true. Can any one post an adduser script?
If you don't respond to help already given, you are not going to get very far here. Did you look at the link BrianK gave you?
Can you answer my earlier questions?
yes it is homework and apparently no one in my entire class knows how to do it. Right now im the only one in class sitting back to try an figure it out as I have to submit it tommorow.I read all the posts but have no clue how to write this script and have been tryin to google for the last 2 hours. The prof said its like a 6-9 line script an I think that isnt true. Can any one post an adduser script?
See my code snippet above. it echos out the user name & gid that you're looking for.
oh yeah an dere is anoder problem also user name has to have 001 all the way to 400... an I think this will give me 1 to 399... not 400 but thats ok because I can create the 400th manually...
Hey brianK its late here I have to leave from college so Ill be back from Home now ,, an try an do the script so i wont reply till I get home. Thanks alot you guys !
hey hey! progress. I don't know why you're using -m? and why are you passing 9999 to -G? I thought $a was for the group?
also, other than confirmation, there's no reason to echo out $i & $a, though leaving it in there for the time being can help you see what's going on.
All this said, I don't remember the initial problem from the other thread, and, to be honest, don't feel like tracking it down, so either repost it here, or let's all continue over there. your choice.
here is what i needed ,, what i wrote in the previous post....
I need a script to create 400 users with username starting from 001 all the way to 400 like user001 all the way to user400. They have to have UID 3001 to 3400 and all shud be in GID 9999. home directories should be /home/user001 all the way to /home/user400 and have a password expiery of 28 days. I am passign 9999 to G because all the users have to be assigned ot the group 9999. The m I suppose is to make a home directory for the user? $a is the UID not group....
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.