Sponsored Content
Top Forums Shell Programming and Scripting KSH script eval(?) to set variable Post 302299564 by tksol on Friday 20th of March 2009 11:21:34 AM
Old 03-20-2009
KSH script eval(?) to set variable

first of all, thanks to all on this board, it has been a huge resource to answer most of my questions!

I am stuck on something that should really be simple, and was looking for some help.. I am using KSH on solaris and working on a script to move containers from server to server. Where i am having problems is setting a variable that should equal a different variable based on the answer..

ie
Code:
print -n "Please select the the zone to move     : "; read ZONENUM
print $zone6 <-this was here for testing to show me the variable is right
ZONENAME=`eval '$'zone$ZONENUM`
print $ZONENAME

basically i have $zone1 $zone2 etc set in the script already, so i just need $ZONENAME=$zone(?) based on which number they select

when i run it i get this:
Code:
Number            Zone Name
===================================================
(1)              sunstage1
(2)              zndvap03
(3)              znbrocade1
(4)              sundev1
(5)              znqaap02
(6)              zndvux01
(7)              zndvux02

Please select the the zone to move     : 7
zndvux01
./zonemgmt2[28]: zndvux02:  not found

so it looks like it is close... Where am i going wrong, or is there a better way to accomplish this?

Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting value of variable set in subprocess script

I am writing a shell script that executes another script by fetching it over the network and piping its contents into sh (ftp -o - $script | sh; or wget -O - |sh). Since this bypasses putting the script on the filesystem, this means I can't source the script directly (using . ), but rather it... (1 Reply)
Discussion started by: hadarot
1 Replies

2. Shell Programming and Scripting

using eval with set, wc, and expr

Okay this is a mess, I'm trying to assign variables with variables in a for-loop. Here is what i have for code. The syntax is not good. Given the following script: #! /bin/csh foreach site (ABC DEF GHI) eval set \t$${site}sf = ``wc -l \$${site}.sf | awk '{print $1}'`` eval set... (2 Replies)
Discussion started by: wxornot
2 Replies

3. Shell Programming and Scripting

eval a variable that has a .

Hi, Is there any way that I can eval the following - eval abc.csv=def.csv I am getting the - bash: command not found error. thanks. (3 Replies)
Discussion started by: ttshell
3 Replies

4. Shell Programming and Scripting

Ksh script - Design ? - Search file and set variables

Hi - I'm trying to think of a clever way to write a shell script (trying to stay w/ ksh as that's what I know the best...) that will resolve the following problem: Problem - On a daily basis I have to email folks who are on-call to remind them. I was hoping to script this out so I could have... (9 Replies)
Discussion started by: littlefrog
9 Replies

5. Shell Programming and Scripting

Eval Tricky Manipulation of Arry in KSH - Help

Hi, Could any one share the intelligence to track this problem. I have any array BT_META_36 and it prints properly with contents of array. # print "BT_META_36=${BT_META_36}" # BT_META_36=cab3,cab4:HDS:052,07A cab3,cab4:HDS:052,07A Now I have a BT_META_36 assigned to a variable.... (0 Replies)
Discussion started by: ajilesh
0 Replies

6. Shell Programming and Scripting

set ksh script in restricted mode

Hi, I came across a post wherein you can use "set -r"(on bash) to activate restricted mode ( wherein you cant run some commands such as cd etc). Can anyone guide if we have anything similar in ksh ? Thanks (2 Replies)
Discussion started by: Shivdatta
2 Replies

7. Shell Programming and Scripting

Sourcing Env file with eval works with ksh but not BASH

Hi, I am running this on Redhat 5.10 I have a simple test script called test.sh which has the following contents and it uses the BASH shebang. ------------------------------------------------------------- #!/bin/bash eval `/tmp/filereader.pl /tmp/envfile.txt` echo "TESTPATH=$TESTPATH" ... (28 Replies)
Discussion started by: waavman
28 Replies

8. Shell Programming and Scripting

ksh - variable to be set to windows path issue

Greetings Experts, I need to pass a parameter to ksh and the value is windows path eg: sh abc.txt C:\Users\chill3chee\Desktop No matter I try with \ delimiter, still could not get this exact value assigned to the shell variable which was checked with echo. Tried with using... (2 Replies)
Discussion started by: chill3chee
2 Replies

9. Shell Programming and Scripting

Getopt eval set parameters not happening when the script is called through an application!

Hi, There is an Informatica tool through which unix scripts can be called. Now the requirement in my project is that a parent script calls a child script but this parent script has to be called through the Informatica tool. In Parent script I'm using TEMP=`getopt -o x:y: -l area:,volume:... (1 Reply)
Discussion started by: Panna
1 Replies

10. UNIX for Beginners Questions & Answers

Eval set -- and more

Hello everyone, I am taking a course on Lynda and they show this code below. I didn't fully understand some parts. Please see the questions within the code. Thank you for your input and time. Regards, function usage { echo Options are -r -h -b -x --branch --version --help --exclude... (9 Replies)
Discussion started by: mohca2020
9 Replies
webminsetup(1m) 														   webminsetup(1m)

NAME
webminsetup - Script to perform initial or update configuration changes to the Webmin server SYNOPSIS
/usr/sfw/bin/webminsetup [-d] DESCRIPTION
webmin(1m) is a web-based tool that provides a set of CGI files, PERL files, and a specialized httpd server for administerin various system facilities and applications on the machine where the Webmin server is running. webminsetup(1m) is used to perform the initial configuration, or to update an existing configuration in the case of an system or Webmin upgrade. Without options, webminsetup(1m) will prompt the user to provide responses for various configuration options. The script will display a default answer for each of the questions, and hitting the return key will select those options. OPTIONS
The following options are available for use with webminsetup(1m); -d Run the script using all of the defaults, and not prompt the user for selections. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWwebminr, | | | SUNWwebminu | +--------------------+-----------------+ |Interface Stability | Evolving | +--------------------+-----------------+ SEE ALSO
webmin(1m), attributes(5) NOTES
In addition to the documentation and man pages included with Solaris, more information is available at http://www.webmin.com 30 Oct 2004 webminsetup(1m)
All times are GMT -4. The time now is 03:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy