Solved

shell scripts problem

Posted on 2002-03-21
9
280 Views
Last Modified: 2010-05-18
Look at this script

set +x
y=SUCCESS
x=y
z=x
echo $`echo $z`
echo "$g"
#exec $g

I am trying to print the value in variable 'y' without using variable 'y'.
In this example i want to print "SUCCESS" without using variable 'y'.

My requirements are like this, can't help this. Actually i am storing a string in variable 'y' which is name of a script i want to execute.

solutions will be greatly apprecaited.

Thanks
GG

0
Comment
Question by:ilikenine
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 6886358
I'm having a bit of a problem understand what you are trying to accomplish. From the first part of your requirement you could do:

x=y
echo $x

which will print what y contains without directly using y.

But it seem from the way the question is phrased that that isn't quite what you want. Could you elaborate, please?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6886688
eval echo \$$x
0
 
LVL 11

Accepted Solution

by:
griessh earned 200 total points
ID: 6886700
Are you doing something like this:

y='ls -l'
z=y
eval $"$z"

======
Werner
0
 
LVL 3

Expert Comment

by:UkWizard
ID: 6887190
Wow, that really does not make sense, what exactly are you trying to do ?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 11

Expert Comment

by:griessh
ID: 6887380
UKWizard

Either ilikenine is just playing ( then (s)he wouldn't offer 200 points ) or there IS a reason behind the problem even if it doesn't make sense to us.

=====
Werner
0
 
LVL 38

Expert Comment

by:yuzh
ID: 6887404
I don't understand what you try to do, may be the following
is the answer for your question:

   set +x
   y=SUCCESS
   x=$y          
   z=$x
   then you can use x and z without directly using y.


0
 
LVL 40

Expert Comment

by:jlevie
ID: 6887425
Yeah, I think that there's a real question here, but the way it's stated doesn't adaquately describe the problem. Hopefully yhe questioner will come back and give us a better descript of the problem.
0
 
LVL 1

Author Comment

by:ilikenine
ID: 6888933
Sorry, agree that i haven't mentioned the problem very clearly.
For the points part, i am new to this place and am not sure how points thing work, don't have the enthu to read either, so i will surely give those points i said. But next time i will be careful that i don't give away points so easily (^_^)

Well my prob:
I have a pram file param.sh
contents :
export JOB1="job1.sh abcd"

export JOB1_STAT=P

Now i have a restart file
contents
JOB1_STAT=R

Now i have my main script, prog.sh
contents:
. param.sh
env | grep -i "JOB" | grep -v "_STAT" | awk '{FS="="} {print $1} | read STEP

Now variable STEP will have the value JOB1
I have to do it like this
. ${$STEP}

Now i tried what griessh said.
I said
eval $"$STEP"
and it is cool... thanks griessh...

Hope this time i am able to mention it clearly.
Thanks
0
 
LVL 1

Author Comment

by:ilikenine
ID: 6888945
Thanks Griessh for that
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now