Sponsored Content
Top Forums UNIX for Advanced & Expert Users Validate if user and group exist Post 302068917 by buffoonix on Tuesday 21st of March 2006 06:47:20 PM
Old 03-21-2006
If you don't want to parse the system user files yourself
you could as well use a system command like id.
e.g.
Code:
echo "enter user:"
read user
if [[ -n $user ]] && id $user >/dev/null 2>&1; then
    # user is known
    # do whatever you like
fi

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What hapens if a group member doesn't exist?

As part of a NIS implementation, (I think) I want to create a group (in /etc/group) that has users that do not exist on the target machine. What effect will this have? Will it cause any problems? Thanks, Gary Cooper (1 Reply)
Discussion started by: Gary Cooper
1 Replies

2. Shell Programming and Scripting

validate input from user for file name

Hello, This may have been addressed already somewhere, however I am looking for the easiest/shortest way to validate a response from a user for a file name. The file name should not have any of the following characters ~`!@#$%^&*()_-+={|\:;"'<,>.?/ Further the response should not have any... (2 Replies)
Discussion started by: jerardfjay
2 Replies

3. Shell Programming and Scripting

validate user ids

Hi I have to validate the user ids. It should be numeric. I am using following code echo $input | grep '^\{11\} > /dev/null if echo "error" else echo "Success" fi But when i entered user id as 828^&% the output is 8565 8566 -bash: ^: command not found Means when i entered... (4 Replies)
Discussion started by: KiranKumarKarre
4 Replies

4. Shell Programming and Scripting

Group Exist Scripting

Hey People, I've got a question! How can i write a function in a script which is looking for if a group exist and if not, that the group "users" is the standard group..I know that i have to use "grep" und "if-else"..I will be very happy for answers ;) Greetz Ali (2 Replies)
Discussion started by: AliC
2 Replies

5. UNIX for Dummies Questions & Answers

Removing a user that doesnt exist from a group

Hi there, normally if I want to remove a user tht I have added to a specific group, i would do the following this is what my group2 looks like # grep group2 /etc/group group2:x:7777:user2,user1,user4 user1 has been defined in a few groups # id -nG user1 group1 group2 group3 So... (3 Replies)
Discussion started by: rethink
3 Replies

6. Red Hat

Removing LVM Volume Group that doesn't exist anymore

Our SAN administrator decided to unpresent then destroy LUN's we were actively using as a volume group (all PV's in said volume group). Now every time I do a pvscan or whatever it complains about I/O errors trying to access those PV's. How do I get it to forget the VG existed completely? vgreduce... (7 Replies)
Discussion started by: thmnetwork
7 Replies

7. Shell Programming and Scripting

How to validate user's input..?

$Input_filename=$ARGV; if (!-d $Input_filename && ! -e $Input_filename) { print "USAGE: Please enter '$ABCD/def/dsed.txt' as an arguement \n"; exit; } 1. Input Is suppose to be something like "$ABCD/def/dsed.txt". if the input is wrong the script should throw an ERROR message.... (2 Replies)
Discussion started by: Rashid Khan
2 Replies

8. Red Hat

User is a Part of a Group But Group Details Do Not Show the User

Hi, In the following output you can see the the user "richard" is a member on the team/group "developers": # id richard uid=10247(richard) gid=100361(developers) groups=100361(developers),10053(testers) but in the following details of the said group (developers), the said user... (3 Replies)
Discussion started by: indiansoil
3 Replies

9. Shell Programming and Scripting

Find if a User exist if not create user

What I'm trying to do is write a script in Perl to find a user and if that user exist it would print "User Exist, Pls Try Again". If The user doesn't exist I'm able to create a user with a password. Any suggestions? (3 Replies)
Discussion started by: GoBoyGo
3 Replies

10. Homework & Coursework Questions

Group Doesn't Exist

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I'm able to create a group but when I'm trying to delete the group it keeps stating Group Doesn't Exist. I know... (2 Replies)
Discussion started by: GoBoyGo
2 Replies
lprm(1) 						      General Commands Manual							   lprm(1)

NAME
lprm - Removes requests from the line printer spooling queue SYNOPSIS
lprm [-Pprinter] [-] [request_ID...] [user...] The lprm command removes one or more requests from a printer's spool queue. OPTIONS
Removes all requests that a user owns. If specified by a user with superuser authority, the spool queue is emptied entirely. Specifies the queue associated with a specific printer; otherwise, the default printer or the value of the PRINTER variable in the environment is used. DESCRIPTION
Because the spooling directory is protected from users, using lprm is normally the way a user can remove a request. The lprm command without any arguments deletes the currently active request if it is owned by the user who invoked lprm. The - flag removes all requests from the user issuing the command. If a user who has superuser authority uses this flag, the spool queue is emptied entirely. The owner is determined by the user's username and hostname on the machine where the lpr command was invoked. You can remove an individual request from a queue by specifying its request ID. (You can obtain the request ID by using the lpq or lpstat commands.) Specifying one or more users removes any requests queued belonging to those users. This works only for a user with superuser authority. The lprm command is silent if there are no requests in the queue that match the request list. The lprm command kills an active daemon, if necessary, before removing any spooling files. If a daemon is killed, a new one is automati- cally restarted upon completion of file removals. NOTES
Because race conditions are possible in the update of the lock file, the currently active request may be incorrectly identified. DIAGNOSTICS
The user tried to remove files that belong to another user. EXAMPLES
To remove a request from the default queue by specifying the request ID, enter: lprm 13 To remove a request from a specific queue, enter: lprm -Plp0 13 To remove from a specific queue a request from user guest, enter: lprm -Plp0 guest FILES
Printer description file. Spool directories. Daemon control files. Data files specified in cf files. Temporary copies of cf files. Lock file used to obtain the process ID of the current daemon and the request ID of the currently active request. SEE ALSO
Commands: lp(1), lpc(8), lpd(8), lpq(1), lpr(1), lpstat(1) lprm(1)
All times are GMT -4. The time now is 02:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy