validating userid


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers validating userid
# 1  
Old 05-07-2003
validating userid

What's wrong with this syntax? It's part of my 'if' statement but it doesn't seem to pass and it keeps going to the 'else' part.

I thought it says that userid must start with a non-numeric character and is between 6 and 10 characters long (alphanumeric).

$userid|grep -Eq '^[a-zA-Z]?\{6,10\}+$'

if [[ $? -eq 0 ]]; then
..
fi

Also, how do I check that a blank in the first character is also NOT acceptable within the same grep command?? '^[a-zA-Z][^ ]?' didn't seem to do it either.

Gianni
# 2  
Old 05-07-2003
This will also make sure the first character is not a space..
Code:
echo $userid | grep -Eq '^[[:alpha:]][[:alnum:]]{5,9}$'
if [[ $? -eq 0 ]]; then
 ..
fi


Last edited by oombera; 05-07-2003 at 05:58 PM..
# 3  
Old 05-07-2003
Also, if this is ksh, you don't need a grep command at all...

Code:
if [[ $id = @([A-Za-z])+([A-Za-z0-9]) &&
      ${#id} > 5 && ${#id} < 11 ]] ; then

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

userid and pw

questions: a. where can I customized the password of userid in solaris? say I wanted 10digits long, all caps? thanks (4 Replies)
Discussion started by: lhareigh890
4 Replies

2. Solaris

See who is logging in with a userid

Hi all. Quick question. How can I tell if someone is logging in to our unix servers with an application id and not their personal id? Thanks (2 Replies)
Discussion started by: jamie_collins
2 Replies

3. UNIX for Dummies Questions & Answers

touch -t time, using different userid

Hi, I am reciveing files from a remote system on my linux box. These files are named based on time, which I can use to 'touch' the time . I can access/modify these files using my id. but when I tried touching time using my id I am getting error; touch -t 1001261234 1001261234_job2333... (15 Replies)
Discussion started by: rajivbravo
15 Replies

4. Shell Programming and Scripting

What is the command to get name associated with userid?

Hi, 1#what is the command to get name associated with userid? 2#I am using unix on Mainframes thru OMVS. So any one know to to capture TSO command output to a variable on OMVS environment. I tried with below script, but its not working! #!/bin/ksh output=$(tso whois PA1234) echo... (6 Replies)
Discussion started by: prashant43
6 Replies

5. Red Hat

userid with nothing to do on the os/app

Hi All, I got this userid apache with the same userid and groupid and /sbin/nologin and the /www/a home folder is empty. Can I just delete this userid? How can I investigate if userid have something to do with the application? Thanks for any comment you may add. (1 Reply)
Discussion started by: itik
1 Replies

6. Shell Programming and Scripting

validating the userid and passwd

Hi i need to write a script which perform some action only when an existing and privliged user is running it. It will call another script where user ID and password are required. So in main script before calling another script I need userID and password validation....for that I can check... (0 Replies)
Discussion started by: ashish_uiit
0 Replies

7. Shell Programming and Scripting

Increment userid in file

Hello, does anyone know how to increment a userid(number) written in any scripting language that works on a shell? For example: I have a HTML file in this format: userid: name: telephone: Every time I execute my script it adds the same fields, except with the userid incremented. Like... (2 Replies)
Discussion started by: dejavu88
2 Replies

8. UNIX for Advanced & Expert Users

userid

I would like to know the difference between the real user-id and the effective user-id. If user-A runs a program owned by user-B then which is the real user-id and which is the effective user-id ? (1 Reply)
Discussion started by: sundaresh
1 Replies

9. Solaris

locking userid to 1 dir?

Hey guys, I need to set up some userid's on Solaris. These userid's will be used to view log files, so I will make the home dir /var/tmp. Is there anyway to make this the only dir that the id has access to? I know about chmod, and short of going thru every file on the box to make sure there is... (2 Replies)
Discussion started by: amheck
2 Replies

10. Shell Programming and Scripting

date and userid

Hi I am trying to write a script to check the log files for the trancactions based on usr input date and user input user id. I will take the user input userid and user input date and check there are any creation deletion happened, if so mail it other wise say no transactions; I got user... (2 Replies)
Discussion started by: gundu
2 Replies
Login or Register to Ask a Question