ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Hold everything: you state here
part of your test file
Turcotte Michael 219 1795259 1795259@bdeb.qc.ca
the file contain 5 column
lastname - firstname - group -DA - email
making 291 the group? I do not know what the DA is. if you're putting this into a loop and reading it in, you will not be able to use different groups for each user as input because your script is running and reading in the contents of the file itself or it should yes? it should read the contents of the file and off your file get all of the information needed to check for group, if no group created group, add user to the system, giving user same group. as it looks all of the groups are the same 219, if that is to be the GID of whatever group you are naming then you are using the same group and GID for everyone.
to cut out the 219 pout of each line in the file using a loop to get to each line, one at a time.
Code:
#!/bin/bash
#1. check if there is 2 parameter
if [ $# -ne 2 ] ; then
{
echo "Please enter 2 parameters"
exit
}
fi
GROUP=$1
FILE=$2
count=1
while IFS= read -r varname; do
FNAME="$(echo $varname | cut -d ' ' -f 1 )"
echo $FNAME
GROUP="$(echo $varname | cut -d ' ' -f 3 )"
echo $GROUP
echo $((count++))
done < "$FILE"
you should be able to figure out the rest from there, taking from everything you've already added to your knowledge base from everyone's response in this post.
the site you gave me is where i found this command line:
PASS=$(Strings/dev/urandom | tr -dc '0-9a-z' | head -c8
i tested it and it work.
this is good, yes? because yours was not working on mine... could have been me, could have been your script with all of the misspelling using caps, whatever, no matter, now you have more options to get the same, yes? carry on dude, and let the penguin be with you.
@snakes3177:
Please review the Site FAQ for guidance in posting your questions and general forum usage.
Do not edit your posts to remove content, especially in a thread which has already received replies. It is disrespectful of those who have taken the time to consider your question and post a reply, and it is harmful to all future visitors who may arrive at this page which now has no context. It degrades the overall quality of information available at LQ and creates a useless link in future search results.
Please remember that your posts will be visible here for a very long time to come, before posting.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.