Solved

shell scripts problem

Posted on 2002-03-21
9
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

696 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