LinuxQuestions.org
Visit Jeremy's Blog.
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 09-10-2004, 12:37 AM   #1
luxpops
LQ Newbie
 
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9

Rep: Reputation: 0
Question why can't i create new group


Hi all, i'm making a script to add user from an input file, it work fine until adding the user to a group name where it says that the group name i want to create is not valid
how do i create new group??
i use the groupadd command and working under red hat fedora core 1
 
Old 09-10-2004, 03:51 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
maybe you did try to add a new group with a gid that already exist ?

Could you post your complete command (with options if any) that you use to create a new group ?
 
Old 09-10-2004, 06:51 AM   #3
hindll01
LQ Newbie
 
Registered: Sep 2004
Location: New Zealand
Distribution: Fedora Core 1
Posts: 13

Rep: Reputation: 0
what have you written as the line of script to add the new group??
 
Old 09-10-2004, 06:10 PM   #4
luxpops
LQ Newbie
 
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9

Original Poster
Rep: Reputation: 0
here is the line of code:

gawk -F: 'BEGIN {n=0}
{system("groupadd " $3);}
{print "Adding user " $1; system("useradd -c " $4 " " $1); n=1}

do u need to specify the gid to make new group??
 
Old 09-10-2004, 08:08 PM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,795

Rep: Reputation: 496Reputation: 496Reputation: 496Reputation: 496Reputation: 496
and what are the parameters you pass to your script ?
why is "$2" not used ?
 
Old 09-10-2004, 09:30 PM   #6
luxpops
LQ Newbie
 
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9

Original Poster
Rep: Reputation: 0
What i want to pass is
Username:Password:Groupname:Fullname

i used $2 in the line of code with the password which i didn't post
 
Old 09-11-2004, 01:36 AM   #7
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Did you try to set -g (primary group) to useradd command with $3 value ?
 
Old 09-11-2004, 03:32 AM   #8
luxpops
LQ Newbie
 
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9

Original Poster
Rep: Reputation: 0
i tried the useradd -g $3
but it sill doesn't create groups, it says useradd: unknown group groupname
 
Old 09-11-2004, 03:58 AM   #9
luxpops
LQ Newbie
 
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9

Original Poster
Rep: Reputation: 0
I finally got it working by using the groupadd command first to create new group if needed
then using the useradd -n -g $3
 
Old 09-11-2004, 03:59 AM   #10
luxpops
LQ Newbie
 
Registered: Sep 2004
Location: new zealand
Distribution: red hat fedora
Posts: 9

Original Poster
Rep: Reputation: 0
thanks Cedrik the -g put me on the right track
 
Old 09-11-2004, 04:15 AM   #11
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
good
 
  


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
can i create a user group at this site? asahlot LQ Suggestions & Feedback 1 10-13-2005 03:08 PM
How to create a new group? neo_in_matrix Linux - Newbie 10 04-01-2005 08:47 AM
How to create a menu group and application launcher? kiranprashant Programming 5 02-26-2005 12:15 AM
how to change/create group password feetyouwell Linux - Software 3 09-06-2004 09:38 PM
Every file I create has a group different than root. How do I find out where this is rfelter Linux - Software 4 04-16-2004 09:28 AM

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

All times are GMT -5. The time now is 04:11 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