Article View: comp.unix.shell
Article #76Re: Variable substitution using Korn shell
From: Eric Ginsberg
Date: Thu, 05 Nov 1992 01:00
Date: Thu, 05 Nov 1992 01:00
39 lines
2151 bytes
2151 bytes
In article <140617@lll-winken.LLNL.GOV>, 946753@arniew.llnl.gov (Arnie Weinstein) writes: > I have a global variable named ASCOM. > ASCOM=/home/aisserver1/people/946753 > The following is the script which reads from standard input the variable > dirnam. Then it test to see if the the contents of dirnam is a directory. If I > enter the full file name manually it works fine, however if I use $ASCOM it does > not work. Instead of substituting the value of $dirname it uses $ASCOM. If the > value of dirnam comes from an input parameter $1 it evalutes the content of $1 > proprely. How do I get dirnam to contain the value of $ASCOM not to contain the > charaters '$ASCOM' ????? > > ********************************************************************************* > read dirnam > if [[ -d $dirnam ]] > then > print $dirnam' to be scanned' > else > print $dirnam' not found' > fi > ********************************************************************************* > > I have tried: > read "dirnam" > > dirn=$echo($dirnam) > if [[ -d $dirn ]] > > Thankyou for any help. Seriously confused and stupified > Arnold Weinstein > Computer Scientist > L.L.N.L Don't feel bad, you're real close. What you're missing is the eval. Add this line in after the read dirnam dirnam=`eval echo $dirnam` Ric Ginsberg eginsber@oracle.com
Technical Details
Message-ID:
<1992Nov5.010000.9474@oracle.us.oracle.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!oracle!unrepliable!bounceReferences:
<140617@lll-winken.LLNL.GOV>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!oracle!unrepliable!bounce
Newsgroups: comp.unix.shell
From: eginsber@oracle.com (Eric Ginsberg)
Subject: Re: Variable substitution using Korn shell
Message-ID: <1992Nov5.010000.9474@oracle.us.oracle.com>
Keywords: KORN Variables
Sender: usenet@oracle.us.oracle.com (Oracle News Poster)
Nntp-Posting-Host: dvlseq
Organization: Oracle Corp
References: <140617@lll-winken.LLNL.GOV>
Date: Thu, 5 Nov 1992 01:00:00 GMT
X-Disclaimer: This message was written by an unauthenticated user
at Oracle Corporation. The opinions expressed are those
of the user and not necessarily those of Oracle.
Lines: 39