On Wed, Jan 02, 2002 at 08:34:25PM -0600, Jamie Ostrowski wrote:
> 
>       I am trying to write a shell script that takes the first argument
> from the command line as the user to whom a file is placed in their home
> directory. I can't seem to get this to run. Normally, it wouldn't be a big
> deal, you'd just do 
> 
>      cp filename /home/$1   
> 
>    but what throws a monkey wrench into the works is that there are
> several different home partitions some users are in home, others in
> home1,home2,home3, etc. and the following doesn't work:
> 
>      cp filename ~${1}/
> 
>    because it interprets the ~ as a character rather than an operator. 
> 
>    Anyone have any ideas how I can get around this? Everytime I try to
> run? Seems you can't combine the ~ with a variable. 
> 

One possible (ugly) solution:

[ ~ ] perl -le 'print +(getpwnam("trammell"))[7]'
/home/trammell
[ ~ ] 

so could something like

 cp filename `perl -e "print +(getpwnam('$1'))[7]"`

be made to work?

-- 
johntrammell at yahoo.com | 78BA 706C C5F9 9321 E7C4 933B D063 907B A88E 924B
Twin Cities Linux Users Group Mailing List (TCLUG)
Minneapolis/St. Paul, Minnesota  http://www.mn-linux.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url : http://shadowknight.real-time.com/pipermail/tclug-list/attachments/20020102/f9779ee1/attachment.pgp