LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-22-2005, 01:19 AM   #16
amer_58
Member
 
Registered: Mar 2004
Distribution: Slackware 10.2
Posts: 213

Original Poster
Rep: Reputation: 30

jonaskoelker it did work,I think you were right, from home it didn't work, when i came to work today i tried it again and it worked, it only added the last one bc the rest were allready added, though when i run the command cat /etc/passwd | cut -d ":" -f1 I couldn't see new users there why! did i have to reboot or sth!! also why do i get this msg after running the script:
Code:
 
usage: useradd  [-u uid [-o]] [-g group] [-G group,...] 
                [-d home] [-s shell] [-c comment] [-m [-k template]] 
                [-f inactive] [-e expire ] [-p passwd] name 
       useradd  -D [-g group] [-b base] [-s shell] 
                [-f inactive] [-e expire ]
I will have to spend some time improving it, bc i want also the script to check if the user is allready exist, if its true then i would a msg saying that the allready user exist.

Thanks.
 
Old 08-22-2005, 02:00 AM   #17
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 46
hmm. Post the complete script, the complete input file, and the output of running the script as `sh -x yourscript.sh'.
 
Old 08-22-2005, 02:23 AM   #18
amer_58
Member
 
Registered: Mar 2004
Distribution: Slackware 10.2
Posts: 213

Original Poster
Rep: Reputation: 30
Script
Code:
root@linux:/home/moderator/Script/adduser/usingS#  sh -x user.sh
+ cat names
+ read first last user
+ /usr/sbin/useradd -c 'test test1' -m test2
+ read first last user
+ /usr/sbin/useradd -c 'alex alex1' -m alex2
+ read first last user
+ /usr/sbin/useradd -c 'john john1' -m john2
+ read first last user
+ /usr/sbin/useradd -c ' ' -m
usage: useradd  [-u uid [-o]] [-g group] [-G group,...]
                [-d home] [-s shell] [-c comment] [-m [-k template]]
                [-f inactive] [-e expire ] [-p passwd] name
       useradd  -D [-g group] [-b base] [-s shell]
                [-f inactive] [-e expire ]
+ read first last user
root@linux:/home/moderator/Script/adduser/usingS#
Input file:
Code:
test test1 test2
alex alex1 alex2
john john1 john2
test2, alex2 and john2 were added + $Home
 
Old 08-22-2005, 02:21 PM   #19
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 46
try `tail -n 1 users.txt'--is the last line blank? That would be the obvious cause of the symptom.

hth --Jonas
 
Old 08-22-2005, 05:08 PM   #20
amer_58
Member
 
Registered: Mar 2004
Distribution: Slackware 10.2
Posts: 213

Original Poster
Rep: Reputation: 30
I got an empty line!!

root@linux:/home/moderator/C++/linux/addusers/Folder2# tail -n 1 name

root@linux:/home/moderator/C++/linux/addusers/Folder2#

where name is the name of the text file.
 
Old 09-20-2005, 11:30 PM   #21
girlay
LQ Newbie
 
Registered: Sep 2005
Posts: 2

Rep: Reputation: 0
i did the script but found an error

hi,

im new to linux.

i just did this script but there's an error.:

#sh -x aduser.sh
+ cat users.txt
+ read first last user
+ /usr/bin/adduser -c 'holiday password' -m test
aduser.sh: line 4: /usr/bin/adduser: No such file or directory
+ read first last user
+ /usr/bin/adduser -c 'jeanne password' -m test2
aduser.sh: line 4: /usr/bin/adduser: No such file or directory
+ read first last user


what seems to be missing?

please help.
 
Old 09-21-2005, 12:06 AM   #22
girlay
LQ Newbie
 
Registered: Sep 2005
Posts: 2

Rep: Reputation: 0
i got the solution!

please ignore my previous post. i already found the cause....its now working well...

one more thing, anybody please help me add the password field in the users.txt and add this in the script???


help please....
 
Old 02-22-2013, 09:09 AM   #23
krrvivek
LQ Newbie
 
Registered: Feb 2013
Posts: 1

Rep: Reputation: Disabled
Lightbulb use this one ..

make a script name test.sh
#vim test.sh
and write these lines in this script
#!/bin/bash
for user in $( seq 10 )
do
useradd vivek$user
echo redhat | passwd --stdin vivek$user
done
#END
:wq
and then run
#./test.sh
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script to add samba users dickohead Programming 11 03-28-2012 06:50 PM
Shell Script: Add Users from file flobadon Programming 3 12-07-2004 03:49 PM
Script to add users ssudhi Linux - Newbie 3 05-01-2004 04:33 AM
Script thats add users automatically embalmedlenin *BSD 1 09-14-2003 04:34 PM
script for creating multiple users d3funct Programming 1 08-21-2001 05:22 PM


All times are GMT -5. The time now is 10:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration