Sponsored Content
Top Forums Shell Programming and Scripting Bash Array connectin to another Array Post 303003618 by batchenr on Sunday 17th of September 2017 08:48:52 AM
Old 09-17-2017
Quote:
Originally Posted by RudiC
Methinks rbatte1 has pointed you in exactly the right direction; you just need to extrapolate / adapt his proposal.
Code:
declare -A names=([IatHG8DC7mZbdymSoOr11w]=hostname1 [KbnlG2j-KRQ0-1_Xk356s8]=hostname2)
for account in ${ACCOUNT_ID[@]};         do echo "ACCOUNT_ID = " $account " has name " ${names["$account"]}; done
ACCOUNT_ID =  IatHG8DC7mZbdymSoOr11w  has name  hostname1
ACCOUNT_ID =  KbnlG2j-KRQ0-1_Xk356s8  has name  hostname2

Thank you!

i was able to do it like this :
Code:
SIP_ACCOUNT_ID=(ohXlWOHKzX8wPSA9SJ e8s-XPBeAgFGel2T3Izt)

declare -A names=([ohXlWOHKzX8wPSA9SJ ]=server2.pbx [e8s-XPBeAgFGel2T3Izt]=server1.pbx)

for account in ${SIP_ACCOUNT_ID[@]}
        do
echo  " ${names["$account"]} :"
done

WORKS! when the account has an issue it shows the name!
thanks againSmilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash array

I'm trying to move files based on a certain day..my question is on array's, what's wrong with the way I'm stepping through the array? what i have gives me syntax errors..any ideas...so far I have #! /bin/bash sun_d=`cal |grep -v |awk '{printf " " $1}' ` echo "$sun_d" ls -l... (1 Reply)
Discussion started by: gubten
1 Replies

2. Shell Programming and Scripting

create array holding characters from sring then echo array.

Hi, I wish to store $string1 in $string1array a character in each array element. Then i wish to echo the entire array to the screen so that it reads as the normal string again. I have been trying with the code below but does not work. Please help... To put string into array: ... (5 Replies)
Discussion started by: rorey_breaker
5 Replies

3. Programming

Creating an array to hold posix thread ids: Only dynamic array works

I am facing a strange error while creating posix threads: Given below are two snippets of code, the first one works whereas the second one gives a garbage value in the output. Snippet 1 This works: -------------- int *threadids; threadids = (int *) malloc (num_threads * sizeof(int)); ... (4 Replies)
Discussion started by: kmehta
4 Replies

4. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

5. Shell Programming and Scripting

perl, put one array into many array when field is equal to sth

Hi Everyone, #!/usr/bin/perl use strict; use warnings; my @test=("a;b;qqq;c;d","a;b;ggg;c;d","a;b;qqq;c;d"); would like to split the @test array into two array: @test1=(("a;b;qqq;c;d","a;b;qqq;c;d"); and @test2=("a;b;ggg;c;d"); means search for 3rd filed. Thanks find the... (0 Replies)
Discussion started by: jimmy_y
0 Replies

6. Shell Programming and Scripting

Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I... (3 Replies)
Discussion started by: dgmm
3 Replies

7. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

8. Shell Programming and Scripting

Array in Bash!

sorry I am new to the bash scripting since I was used to c shell programming. I am writting a script in bash for which I have to create an array in bash. I was able to do parse one variable through command line by doing": Lets say the below code is part of temp.bash and is called like: temp.bash... (5 Replies)
Discussion started by: dixits
5 Replies

9. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

10. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies
qmail-getpw(8)                                                System Manager's Manual                                               qmail-getpw(8)

NAME
qmail-getpw - give addresses to users SYNOPSIS
qmail-getpw local DESCRIPTION
In qmail, each user controls a vast array of local addresses. qmail-getpw finds the user that controls a particular address, local. It prints six pieces of information, each terminated by NUL: user; uid; gid; homedir; dash; and ext. The user's account name is user; the user's uid and gid in decimal are uid and gid; the user's home directory is homedir; and messages to local will be handled by home- dir/.qmaildashext. In case of trouble, qmail-getpw exits nonzero without printing anything. WARNING: The operating system's getpwnam function, which is at the heart of qmail-getpw, is inherently unreliable: it fails to distinguish between temporary errors and nonexistent users. Future versions of getpwnam should return ETXTBSY to indicate temporary errors and ESRCH to indicate nonexistent users. RULES
qmail-getpw considers an account in /etc/passwd to be a user if (1) the account has a nonzero uid, (2) the account's home directory exists (and is visible to qmail-getpw), and (3) the account owns its home directory. qmail-getpw ignores account names containing uppercase let- ters. qmail-getpw also assumes that all account names are shorter than 32 characters. qmail-getpw gives each user control over the basic user address and all addresses of the form user-anything. When local is user, dash and ext are both empty. When local is user-anything, dash is a hyphen and ext is anything. user may appear in any combination of uppercase and lowercase letters at the front of local. A catch-all user, alias, controls all other addresses. In this case ext is local and dash is a hyphen. You can override all of qmail-getpw's decisions with the qmail-users mechanism, which is reliable, highly configurable, and much faster than qmail-getpw. SEE ALSO
qmail-users(5), qmail-lspawn(8) qmail-getpw(8)
All times are GMT -4. The time now is 03:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy