Arrays display - not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Arrays display - not working
# 1  
Old 01-10-2007
Data Arrays display - not working

Hi,
I could not make this one working. Any help is appreciated. I am trying to display days & months. The code is failing at line 13 " for i in ${{$filea}[@]} ". Please help.

#-----------------------------------
#!/bin/ksh
#
DAY="mon tue wed thu fri sat sun"
MONTH="jan feb mar apr may june july aug sep oct nov dec"
ARRX="pday month"
set -A pday $DAY
set -A month $MONTH
set -A arrx $ARRX
for filea in ${arrx[@]}
do
#echo $filea
#for i in ${pday[@]}
for i in ${{$filea}[@]}
do
echo $i

done
done
#------------------------------------

Thanks.
Ron
# 2  
Old 01-10-2007
About as close as you can come to something like that will require an eval:
Code:
#!/bin/ksh
#
DAY="mon tue wed thu fri sat sun"
MONTH="jan feb mar apr may june july aug sep oct nov dec"
ARRX="pday month"
set -A pday $DAY
set -A month $MONTH
set -A arrx $ARRX
for filea in ${arrx[@]} ; do
        for i in $(eval echo \${$filea[@]}) ; do
                echo $i
        done

done
exit 0

# 3  
Old 01-11-2007
Bug You are a genius.

The problem is solved. Thanks. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Disk Space Utilization in HTML format working in one environment and not working on the other

Hi Team, I have written the shell script which returns the result of the disk space filesystems which has crossed the threshold limit in HTML Format. Below mentioned is the script which worked perfectly on QA system. df -h | awk -v host=`hostname` ' BEGIN { print "<table border="4"... (13 Replies)
Discussion started by: Harihsun
13 Replies

2. Shell Programming and Scripting

Working web service call not working with curl

Hello, Newbie here, I have a perfectly well working web service call I can issue from chrome (PC Windows 10) and get the results I want (a dimmer being turned on in Fibaro Home Center 2 at level 40) I am not allowed to post urls but the below works with http and :// and... (3 Replies)
Discussion started by: abigbear
3 Replies

3. Shell Programming and Scripting

Automating pbrun /bin/su not working, whenever manually it is working using putty

I am trying to automate a script where I need to use pbrun /bin/su but for some reason it is not passing thru the pbrun as my code below. . ~/.bash_profile pbrun /bin/su - content c h 1 hpsvn up file path I am executing this from an external .sh file that is pointing to this scripts file... (14 Replies)
Discussion started by: jorgejac
14 Replies

4. Shell Programming and Scripting

Cat command not working to display Mac file in Ubuntu

Hi, Recently I got a .txt file from Mac user. when I try to open it in my Ubuntu machine using cat command it is not displaying any content of file however I can see the content using vi. Anyone know How to see its content using cat as I have to process it in my shell script. Thanks in... (4 Replies)
Discussion started by: diehard
4 Replies

5. AIX

Keyboard Mouse Display not working with Pseries

Hello, Just got a refurbished Pseries when I boot the machine , everything is okay, that is no attention light and panel shows 01 B N but there is nothing on the display ( monitor / console ) which is plugged into the video card port of pseries. The display is empty.... The keyboard... (3 Replies)
Discussion started by: filosophizer
3 Replies

6. Programming

question about int arrays and file pointer arrays

if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies

7. UNIX for Advanced & Expert Users

DISPLAY=local_host:0.0 ; export DISPLAY

Hi, from my Windows Workstation I can connect with PUTTY to an AIX 6.1 unix server. On AIX via PUTTY I run DBCA which has a grphical interface. Then : #DISPLAY=local_host:0.0 ; export DISPLAY $(hostname) $(whoami):/appli/oracle/product/10.2.0/db_1/bin#dbca _X11TransSocketINETConnect()... (12 Replies)
Discussion started by: big123456
12 Replies

8. Web Development

PHP arrays in arrays

PHP question... I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names. So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person with values "Fred", "Bert", "Tom" etc So what I want to do is display the... (3 Replies)
Discussion started by: JerryHone
3 Replies

9. Shell Programming and Scripting

working with arrays

Hi, I'm writting a script to assign sm values to arrays and work on the values stored in array later. But i'm not able to work properly to use these arrays. intialising is one of the main problem as i'm not sure of array element count (they can increase/decrease). Copying the script. In case of... (4 Replies)
Discussion started by: raman1605
4 Replies
Login or Register to Ask a Question