I am working on a application , which adds unix user through useradd and deletes user through userdel . both are admin commands .
My requirement is i have to add a user into at.allow whenver a unix user is added through my application and the user should be deleted from at.allow whenever a user is deleted from my application .
is there any way i can do this through a C program or a shell script .
for at.allow addition i can write a small script having a line
echo "Bill" >> /var/adm/at.allow .
but if i want to delete the same bill in at.allow , how can i delete from at.allow .
is there any specific way to do this through a command or a program.
IN simple words i have to update the file with new user and delete the existing user from at.allow.
You can use a small script for deletion as well. Use grep/sed/awk/ex to remove the unwanted userid, output to a temp file, move the temp file back over the at.allow file.
Are you using a C program to do this or a shell script? You can use lockf in C. It allows record level locking of files, but if you do that, I am not sure that you can use another script to update the file.