Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the '10.5: Delete users accounts from command line in 10.5' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Delete users accounts from command line in 10.5
Authored by: wallybear on Jun 10, '09 02:15:11PM

Two simple changes to address the two issues of your script (the hardcoded user name and script name):

You can get the short ID 501 user name with the command: id -un 501
So if you add this

USERNAME=`id -un 501`

at the beginning of your script and then substitute all "username" occurrences with $USERNAME you get the automatic user detection you wished for.

Secondly, you can get the full pathname of the called script using the $0 variable, so you can substitute the lines:

# remove this script
rm /

with those:

# remove this script
rm $0

and the script will be deleted doesn't matter which name you gave it.

[ Reply to This | # ]