LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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


Reply
  Search this Thread
Old 10-17-2013, 04:12 AM   #1
peterdin
LQ Newbie
 
Registered: Oct 2013
Posts: 21

Rep: Reputation: Disabled
Script to block userid creation more that 8 characters


Hi Guys,

I have one script which is used to add new user in the system.

This is how we add new user in system:-

Code:
 sudo /opt/local/bin/new-user 114 ranivarm "Rani Varma(Libo Technical User)" INC00001111

Where
114:-is the site id
ranivarm:- is userid
"Rani Varma(Libo Technical User)" :- comment
INC00001111:- ticket number

The script is little big, so here is part of that script:-
Code:
case $steps2skip in
(help)  die "$advanced";;
(password)      steps2skip=124;;
(enable)        steps2skip=123;;
([1-4]*)        ;;
esac

username=${1:?username required: $usage} shift
ticket=$3
descr="$*"


#
# assertions
#

grep -c ${group}  /etc/group >/dev/null ||
        warn "Warning: group $group is not in /etc/group"

grep -c $shell /etc/shells >/dev/null ||
        warn "Warning: shell $shell is not in /etc/shells"



warn "Checking accountname ${username:?}"

if [[ $steps2skip = *1* ]]; then

        /bin/logins -xol $username ||
                die "account $username does not exist!"
        /bin/getent passwd ${username} ||
                die "account $username does not exist!"

        eval home=~${username}

else    : step 1: creating /etc/passwd entry

        /bin/getent passwd ${username} &&
                die "account $username already exists!"
        /bin/logins -xol $username

Could you please tell me what entry should I enter and where should I insert it?

Thanks
Peter
 
Old 10-17-2013, 06:55 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Code:
username=${1:?username required: $usage} shift
[ ${#username} -gt 8 ] && die "username length > 8."
 
1 members found this post helpful.
Old 10-17-2013, 10:47 AM   #3
peterdin
LQ Newbie
 
Registered: Oct 2013
Posts: 21

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by unSpawn View Post
Code:
username=${1:?username required: $usage} shift
[ ${#username} -gt 8 ] && die "username length > 8."
Thanks a lot for this. But my main problem is where exactly to insert these lines as this script is way big created by someone in 2005.
Would you please guide me where exactly can I insert these lines? can I insert it anywhere in script/

Thanks a lot!
 
Old 10-17-2013, 04:50 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Look up the first line I posted in your script and post the second one beneath it.
 
  


Reply



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
Need help regarding Userid creation in 400 Linux boxes redhat70 Linux - General 4 06-01-2012 01:54 PM
UserID composed of Korean characters not recognized in RHEL vinitpail Linux - Newbie 1 05-30-2008 12:55 AM
Check userid/password from a script/program johann_p Programming 6 11-09-2006 05:09 AM
sql script to find out the userid Prasun1 Linux - General 5 07-01-2005 09:54 AM

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

All times are GMT -5. The time now is 11:25 AM.

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