Dynamic Varibles problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dynamic Varibles problem
# 1  
Old 04-28-2005
Dynamic Varibles problem

All,
Any chance someone could help me with this.... The script is reading from a file and for every line of input to the loop I am trying to assign a new varible. When i run the script I get the below errors. I have come to a bit of a dead end so any pointers/help would be very much appriciated...

Cheers nathan Smilie

i=1
while read -r LINE
do
DISK_FOUND$i=$LINE
((i=i+1))
done < FILE_SYSTEMS


and the output i get...

wipe_disk_select.ksh[19]: DISK_FOUND1=/dev/md/dsk/d0: not found
wipe_disk_select.ksh[19]: DISK_FOUND2=/dev/md/dsk/d3: not found
wipe_disk_select.ksh[19]: DISK_FOUND3=/dev/md/dsk/d5: not found
wipe_disk_select.ksh[19]: DISK_FOUND4=/dev/md/dsk/d4: not found
# 2  
Old 04-28-2005
Why not use an array?

DISK_FOUND[i]=$LINE
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash, Dynamic Variable Problem >.<

Hello, I have a problem with a bash script, I've been doing recherches but i can't make it work. It is my first time with a dynamic variable and i don't understand how to write it. #!/bin/bash USER=BARSPIN HOTKEYS_PATH="/home/$USER/Documents/bash/tibia/HOTKEYS" CFG1="A" CFG2="B"... (5 Replies)
Discussion started by: barspin
5 Replies

2. Shell Programming and Scripting

Dynamic Variable data problem

Hi, I am trying to call this variable declared globally STATE=`/opt/Mic*/bin/mstrctl -s IntelligenceServer gs | grep "state" | cut -f2 -d'<' | cut -f2 -d'>'` which extracts the status of a microstrategy server inside the loop. But once the value is assigned initially in the begining, it is not... (5 Replies)
Discussion started by: kavinmjr
5 Replies

3. Programming

problem in dynamic library*.so

hello I apologize if my question bothers you I work on a code developed in C + + which worked well on mac os, this code will help create libraries *.so from *.cc and *.h I used this as flags:CXXFLAGS = -g -O2 -fPIC -Wall -ldl -D_GNU_SOURCE ,CXX := g++ and $(CXX)-shared -o $(LIBNAME) $(CLIBLIB)... (0 Replies)
Discussion started by: pheapc
0 Replies

4. Shell Programming and Scripting

Passing varibles as a string argument ?

For example test.sh: test="teststring" cmd=$1 $cmd For some reason I'm NOT seeing "teststring" when I type: ./test.sh "echo $test" Any ideas on how to get around this? I've tried commands like: ./test.sh "echo $($test)" ./test.sh "echo '$test'" And many variations to no... (6 Replies)
Discussion started by: secops
6 Replies

5. Shell Programming and Scripting

Multiple varibles in file

Working on a way to speed up my script output. I have a multiline file that I pull each line as a variable and post it on a webpage. It needs some help as it works but slow. I think I have too many cat, grep and sed going on but don't know what would work better. #!/bin/sh... (5 Replies)
Discussion started by: numele
5 Replies

6. UNIX for Dummies Questions & Answers

Problem with shared dynamic library files

I am having a major problem. Most of the commands that i am running on my centos 5 system is giving the error of type: <dynamic shared library file>:open failed: No such file or directory For example: libgcc_s.so.1: open failed: No such file or directory How can i solve this? (6 Replies)
Discussion started by: proactiveaditya
6 Replies

7. Shell Programming and Scripting

Problem with dynamic variables outside the loop

Hi All, Shell is ksh I've given portion of the script here to explain the problem. It will accept 2 input parameters . in_file1=$1 in_file2=$2 outbound_dir=/home/outbound for i in 1 2 do eval file$i=$outbound_dir/\$in_file$i eval echo "filename is \$file$i" ... (4 Replies)
Discussion started by: kk17
4 Replies

8. UNIX for Dummies Questions & Answers

How to create ENV varibles

Hi, I want create env variable for "/ramakrsihna/scripts" help me on this. (1 Reply)
Discussion started by: koti_rama
1 Replies

9. UNIX for Dummies Questions & Answers

different way to echo varibles...help

Given the following loop: foreach id (DB4 GH4 CD4) and the previously defined variables: DB4sf DB4sfk DB4pp GH4sf GH4sfk GH4pp CD4sf CD4sfk CD4pp how do i echo all of these variables using a one line command in the for loop. If it was a script, and assuming the previously mentioned... (8 Replies)
Discussion started by: wxornot
8 Replies

10. UNIX for Dummies Questions & Answers

environmental varibles

flavor -- AIX 4.2.1 I am putting together some HTML pages, some of which contain forms. The problem pops up when I attempt to pass variables (from the forms) from one HTML page to a cgi-like page created using ksh. I have used the $1 - $9 vars, but they do not work with the passing. With... (1 Reply)
Discussion started by: Xiix
1 Replies
Login or Register to Ask a Question