LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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


Closed Thread
  Search this Thread
Old 02-04-2018, 06:20 PM   #16
snakes3177
LQ Newbie
 
Registered: Feb 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled

allo

Last edited by snakes3177; 02-18-2018 at 09:48 AM.
 
Old 02-04-2018, 06:39 PM   #17
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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.

if not then feel free to ask more questions.

Last edited by BW-userx; 02-04-2018 at 06:43 PM.
 
Old 02-04-2018, 06:44 PM   #18
snakes3177
LQ Newbie
 
Registered: Feb 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
allo

Last edited by snakes3177; 02-18-2018 at 09:48 AM.
 
Old 02-04-2018, 07:19 PM   #19
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
different methods of generating a password in Linux

https://www.howtogeek.com/howto/3018...-command-line/
 
Old 02-05-2018, 07:42 AM   #20
snakes3177
LQ Newbie
 
Registered: Feb 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
allo

Last edited by snakes3177; 02-18-2018 at 09:48 AM.
 
Old 02-05-2018, 08:57 AM   #21
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Quote:
Originally Posted by snakes3177 View 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.

Last edited by BW-userx; 02-05-2018 at 09:02 AM.
 
Old 02-18-2018, 06:07 PM   #22
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,276
Blog Entries: 24

Rep: Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224Reputation: 4224
@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.

This thread is now closed.
 
1 members found this post helpful.
  


Closed Thread



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
Debian Bash Script Help Please... ilovepoker Linux - Newbie 1 10-02-2014 07:30 PM
Migrating mail server from debian 5 to debian 6- Maildir folder renaming script asylum_craig Linux - Server 1 04-05-2013 06:46 AM
debian 6.0.4 init script pini Debian 1 03-10-2012 06:19 AM
Shell script to compile a custom Linux kernel on Debian-based systems Kenny_Strawn Linux - Kernel 3 09-25-2010 01:29 PM
Equivalent pw script in Debian or any Linux? lunajlt Linux - General 2 12-21-2005 03:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:48 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration