Solved

shell scripts problem

Posted on 2002-03-21
9
283 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 3

Expert Comment

by:UkWizard
ID: 6887190
Wow, that really does not make sense, what exactly are you trying to do ?
0
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

808 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