[wplug] need to find user HOME dir

Bob Schmertz rschmertz at speakeasy.net
Tue Jul 1 02:37:41 EDT 2003


Gentgeen incurred the wrath of Bob on Jun 30, by saying

>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.

I would tar up the files from the first user's account, put it somewhere
where the second user can find it, and have the second user untar it
into his home directory.

BTW, I'd use the variable '$#' to check number of arguments before 
setting FILENAME and USERNAME, and avoid checking for the nullness of 
those two later on.

>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
>

-- 
Cheers,
Bob Schmertz





More information about the wplug mailing list