Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

shell scripts problem

Posted on 2002-03-21
9
Medium Priority
?
288 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 600 total points
ID: 6886700
Are you doing something like this:

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

======
Werner
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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…
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…
Suggested Courses

730 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