Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i need help with a shell script that passes a variable.why does this not work?:
echo $`echo 1`
i want this to produce the same result as
echo $1
but instead of the first option given at the commandline i get "$1" as result.
here is the script if u are interested in what i want to achieve:
any thoughts appreciated.#!/bin/bash
if [ ! $ORACLE_HOME ]; then
echo "ORACLE_HOME unset. exiting."
exit 1
fi
if [ $(basename `echo $ORACLE_HOME`) == "9i" ]; then
LOGS="$ORACLE_HOME/j2ee/Oracle9iDS/log/ $ORACLE_HOME/j2ee/Oracle9iDS/application-deployments/forms/"
fiif [ $(basename `echo $ORACLE_HOME`) == "9iAS" ]; then
LOGS="$ORACLE_HOME/j2ee/Oracle9iAS/log/ $ORACLE_HOME/j2ee/Oracle9iAS/application-deployments/forms/"
fi
echo -e "\n\nLogfile sizes:\n\n"
for l in $LOGS; do
echo -e "\n$l\n"
ls -lah $l
doneecho -e "\n\nGo to...\n\n"
for i in $LOGS; do
if [ ! $X ]; then
X=1
else
X=`expr $X + 1`
fi
echo "$X $i"
done
read -p "Choice: " SELset $LOGS
DIR=$`echo $SEL`
echo $DIR
#cd $`echo $SEL` && bash

Perhaps I'm missing a point but does
DIR=$SELnot work for you? Otherwise I think eval() would help you.

> Perhaps I'm missing a point but does
> DIR=$SEL
> not work for you? Otherwise I think eval() would help you.well, SEL will hold a number...for example "1"
in this case i want DIR to hold "$1" so i would like $$SEL. get it?
but if i do it like that bash interprets it as $$ and SEL instead of $ and $SEL.:(
eval() looks much like a c function to me is it?
i would like to stick with bash. i know there is a bash builtin called eval but this does something completely different, doesnt it?

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |