1846622 Members
1359 Online
110256 Solutions
New Discussion

Re: newuser script help

 
SOLVED
Go to solution
Nick D'Angelo
Super Advisor

newuser script help

Script gurus,

I have a script that I run to add new users but if the username has a double letter, ie mccullou for Mccullou, it drops the second letter.

Any suggestions? By the way, I have attached it for your review.

Suggestions are appreciated,

Thanks,
Always learning
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: newuser script help

Hi Nick:

Your problem is your your tr -s "[A-Z]" "[a-z]"

Drop the -s and try again.

Clay
If it ain't broke, I can fix that.
Sachin Patel
Honored Contributor

Re: newuser script help

Hi Nick
Use this in you script

user= `echo $1 |tr "[:upper:]" "[:lower:]"`

this will convert $1=username in to lowercase and will not remove any character.

Sachin
Is photography a hobby or another way to spend $
James R. Ferguson
Acclaimed Contributor

Re: newuser script help

Nick:

The problem is the '-s' option to 'tr' You are squeezing multiple instances of the characters you are translating to a single instance.

Regards!

...JRF...
Kelli Ward
Trusted Contributor

Re: newuser script help

Hi,
I admit it, I'm not a script guru, far from it, but I love to tinker. Although, I have not had time to try you script, I did look at it.
I think your problem may be stemming from the uniq command in line 10. Check your man pages, I think you may need to add an option to get it to recognize double characters.
Or you could alway use SAM ; )
Hope this helps,
K
The more I learn, the more I realize how much more I have to learn. Isn't it GREAT!
Magdi KAMAL
Respected Contributor

Re: newuser script help

Hi ,

As said before, delete the tr 's option "-s" in the following line:

user=`echo $1 | tr "[A-Z]" "[a-z]"

and it will work !

Magdi
Nick D'Angelo
Super Advisor

Re: newuser script help

Thank you all for your answers.

I was not able to login earlier due to login problems with the HP authentication server.

Nickd
Always learning
Praveen Bezawada
Respected Contributor

Re: newuser script help

Hi
You can use typeset

typeset -u $UPPERCASE=$LOWERCASE

...BPK...