[wplug] need to find user HOME dir

Gentgeen gentgeen at linuxmail.org
Mon Jun 30 23:53:09 EDT 2003


I am writing a little script to copy things from one users account to
a second users account, and then change the owner and group settings to
the 2nd user.

The basic reason is that I am currently setting up a new laptop, and
after I get all the 'dot' files and assorted 'rc' files setup the way I
want within the root account, I then want to copy they over to my user
account so I won't have to do it all over.  The script looks like this
for now:
################################################################
#! /bin/sh
# Usage:   cpchmod <arguement 1> <arguement 2>
#                   arguement 1 is the name of the file to copy
#                   arguement 2 is the name of the user
# Assign better names to the arguements
FILENAME=$1
USERNAME=$2

#Test for both arguements
if test "$FILENAME"=""; then
	echo "Usage: cpchmod <arguement 1> <arguement 2>
	exit
fi

if test "$USERNAME"=""; then
	echo "Usage: cpchmod <arguement 1> <arguement 2>
	exit
fi

# Check for the existance of the file with 'test -e'
#
#
# Check for the users home directory
#
#
HOMEDIR='/home/kevin'

# Now do what we want to do
cp $FILENAME $HOMEDIR/
chown $USERNAME:$USERNAME $HOMEDIR/$FILENAME
exit
##########################################################

As of now it does what I want, but I would like to make it a little more
generic so I can use it on the server that I run at school.  I wand to
add a way to set the HOMEDIR from the USERNAME. I think I would do this
via the /etc/passwd file, but I do not know how to get the info from
that file.  

Could anyone help out with this one?  If there is a better way to do
this I would appriciate it as well, but I would still like to know the
above, just for the sake of knowing.

NOTE- I know about using /etc/skel/, but this script is for accounts
already made.



More information about the wplug mailing list