Computing.Net > Forums > Linux > advanced shell script help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

advanced shell script help

Reply to Message Icon

Name: armin
Date: January 7, 2003 at 03:44:17 Pacific
OS: debian 3.0
CPU/Ram: enough of both
Comment:


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/"
fi

if [ $(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
done

echo -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: " SEL

set $LOGS

DIR=$`echo $SEL`

echo $DIR


#cd $`echo $SEL` && bash



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: January 7, 2003 at 05:04:43 Pacific
Reply:

Perhaps I'm missing a point but does
DIR=$SEL

not work for you? Otherwise I think eval() would help you.


0

Response Number 2
Name: armin
Date: January 7, 2003 at 05:53:09 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: advanced shell script help

shell script help www.computing.net/answers/linux/shell-script-help/15420.html

begginner shell script help ASAP! www.computing.net/answers/linux/begginner-shell-script-help-asap/18683.html

Shell Script - help www.computing.net/answers/linux/shell-script-help/21347.html