The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting Array Elements msb65 UNIX for Dummies Questions & Answers 3 10-21-2008 02:29 PM
[Perl] Accessing array elements within a sed command in Perl script userix Shell Programming and Scripting 2 10-03-2008 12:05 PM
Accessing single elements of a awk array in END timj123 Shell Programming and Scripting 6 06-20-2008 04:53 PM
Rearrange array elements-Pls help tj23 Shell Programming and Scripting 4 06-20-2008 09:29 AM
To return the elements of array Sudhakar333 Shell Programming and Scripting 5 08-06-2007 02:20 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-30-2008
mansa mansa is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 33
Accessing array elements

Hi,

My doubt is how to access array elements..
Situation is as below:


Code:
 
#!/bin/ksh
set -x
typeset -i x=0
typeset -i y=0
typeset -i BID=0
typeset -i count=0
while [[ $BID -le 35 ]] ; do
        x=`expr $x + 1`;
        hwmgr show scsi > scsi.tmp
        while read line; do
                set -A a
                a[x]=`echo $line | grep "dsk" | awk '{ print $7 }'`
        done < scsi.tmp
        echo ${a[0]}
        echo ${a[1]}
        echo ${a[2]}
        BID=`expr $BID + 35`;
done
Otuput:
======

Nothing displays here..


Could you please modify the above code to get correct output..

Please provide your inputs ....


Thanks,
mansa
  #2 (permalink)  
Old 10-30-2008
mansa mansa is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 33
Hi,

In my previous update i forgot to mention the "scsi.tmp" file contents..

$ cat scsi.tmp

SCSI DEVICE DEVICE DRIVER NUM DEVICE FIRST
HWID: DEVICEID HOSTNAME TYPE SUBTYPE OWNER PATH FILE VALID PATH
-------------------------------------------------------------------------
68: 0 mullins disk none 0 1 dsk0 [0/0/0]
69: 1 mullins disk none 0 1 dsk1 [0/1/0]
71: 4 mullins disk none 0 4 scp0 [2/0/0]
72: 5 mullins disk none 2 4 dsk2 [2/0/3]
73: 6 mullins disk none 2 4 dsk3 [2/0/4]
74: 7 mullins disk none 2 4 dsk4 [2/0/6]
75: 8 mullins disk none 2 4 dsk5 [2/0/7]


Please provide your inputs on this..

Thanks in Advance,
Mansa
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0