[comp.unix.admin] Korn Tilde expansion

stevedc@syma.sussex.ac.uk (Stephen Carter) (02/04/91)

Sequent Dynix - Korn Shell tilde (~) expansion
----------------------------------------------

In trying to write a (very naive) script on my Sequent Symmetry running
Dynix 3.0.17 we have run into a problem on tilde expansion.

(Dynix is basically Berlekly Unix with an
application level System V sitting on top).  For those readers who know
Dynix we are using SVAE.

The script merely eases the problems of the operators in moving files
from one user's account to another, and then remembering to change the
ownership and group.  It asks for 4 parameters in turn (from, to,
newowner and newgroup).

We want to allow the operators the option of entering (eg)
~stevec/foo.txt instead of having to enter
/user3/division/section/stevec/foo.

However, try as we may, we cannot get the following logic (or a wide
range of variants of it to work:

#!/bin/ksh
#       .
#       .  cuts here to make it shorter

echo "  from  (eg /user2/pers/artemish/wp1/file1.txt) : \c"
read from
echo "  to    (eg /user2/pers/elinorm/wp1/file1.txt)  : \c"
read to
echo "  new owner (eg elinorm)   		      : \c"

#	More cuts (eg testing access/ to file not existing etc)

        mv $from $to

We have tried it with and without single quotes, double quotes, curly
brackets... 

Question:  Can it be done?  If so how?  If not on Dynix, then is this
inability a 'feature' of Dynix.

Thanks

Stephen Carter, Systems Manager, The Administration,
The University of Sussex, Falmer, Brighton BN1 9RH, UK
Tel: +44 273 678203  Fax: +44 273 678335     JANET: stevedc@uk.ac.sussex.syma
EARN/BITNET  : stevedc@syma.sussex.ac.uk      UUCP: stevedc@syma.uucp
ARPA/INTERNET: stevedc%syma.sussex.ac.uk@nsfnet-relay.ac.uk 

leclercq@bachus.enet.dec.com (Philippe Leclercq) (02/05/91)

Path: bachus.enet.dec.com!leclercq
Newsgroups:
sussex.general,comp.sys.sequent,comp.unix.questions,comp.unix.misc,comp.
.unix.admin
Distribution: world
References: <4401@syma.sussex.ac.uk> 
From: leclercq@bachus.enet.dec.com (Philippe Leclercq)
Message-ID: <1991Feb5.100042@bachus.enet.dec.com>
Reply-To: leclercq@bachus.enet.dec.com (Philippe Leclercq)
Organization: Digital Equipment Corporation
Subject: Re: Korn Tilde expansion
Keywords: korn tilde

In article <4401@syma.sussex.ac.uk>, stevedc@syma.sussex.ac.uk (Stephen Carter)
writes:
|> 
|> Sequent Dynix - Korn Shell tilde (~) expansion
|> ----------------------------------------------
|> 
|> In trying to write a (very naive) script on my Sequent Symmetry running
|> Dynix 3.0.17 we have run into a problem on tilde expansion.
|> 
|> We want to allow the operators the option of entering (eg)
|> ~stevec/foo.txt instead of having to enter
|> /user3/division/section/stevec/foo.
|> 
|> However, try as we may, we cannot get the following logic (or a wide
|> range of variants of it to work:
|> 
|> #!/bin/ksh
|> #       .
|> #       .  cuts here to make it shorter
|> 
|> echo "  from  (eg /user2/pers/artemish/wp1/file1.txt) : \c"
|> read from
|> echo "  to    (eg /user2/pers/elinorm/wp1/file1.txt)  : \c"
|> read to
|> echo "  new owner (eg elinorm)   		      : \c"
|> 
|> #	More cuts (eg testing access/ to file not existing etc)
|> 
|>         mv $from $to
|> 
|> We have tried it with and without single quotes, double quotes, curly
|> brackets... 
|> 
|> Question:  Can it be done?  If so how?  If not on Dynix, then is this
|> inability a 'feature' of Dynix.
|> 
|> Thanks
|> 

We have the same behavior on ULTRIX.
Substitute your last command by :

eval "mv $from $to"

It should work.

-Philippe Leclercq
  Support System Engineer
   DEC Brussels, Belgium.

petebob@sequent.UUCP (Pete_Bob Apple) (02/06/91)

In article <4401@syma.sussex.ac.uk> stevedc@syma.sussex.ac.uk (Stephen Carter) writes:
>Sequent Dynix - Korn Shell tilde (~) expansion
>----------------------------------------------
>
>We want to allow the operators the option of entering (eg)
>~stevec/foo.txt instead of having to enter
>/user3/division/section/stevec/foo.
>
>However, try as we may, we cannot get the following logic (or a wide
>range of variants of it to work:
>
<shell script deleted>
>
>We have tried it with and without single quotes, double quotes, curly
>brackets... 
>
>Question:  Can it be done?  If so how?  If not on Dynix, then is this
>inability a 'feature' of Dynix.

#!/bin/ksh
#       .
#       .  cuts here to make it shorter

echo "  from  (eg /user2/pers/artemish/wp1/file1.txt) : \c"
read from
eval from=$from
echo $from


Hope this helps.  Ksh on Dynix is (hopefully) equivalent to ksh on any
other machine.  (That's what we had in mind, anyway.  :-)

-- 
Pete_Bob Apple						Sequent Computer Systems
petebob@sequent.com, sequent!petebob			15450 S.W. Koll Parkway
Bob is not just a name..				Beaverton, Oregon 97006
It's a way of life.. 					(503) 626-5700