Sponsored Content
Top Forums Shell Programming and Scripting Filter output as an array element Post 302630235 by paslas on Wednesday 25th of April 2012 02:28:15 PM
Old 04-25-2012
Filter output as an array element

I am filtering the value of Server status from a file and am storing it in a temp file which I compare later to exit with appropriate status. I am wondering if I can directly output the value of Server status as an array element and then compare the value of elements to get the right exit status

Code:
#!/bin/csh -f
cat srvoff | /usr/bin/grep -i 'Tx Server Status' | /usr/bin/awk '{print $4}' > /tmp/status
cat srvoff | /usr/bin/grep -i 'Eg Server Status' | /usr/bin/awk '{print $4}' >> /tmp/status
cat srvoff | /usr/bin/grep -i 'ASM Server Status' | /usr/bin/awk '{print $4}' >> /tmp/status
cat srvoff | /usr/bin/grep -i 'Int server' | /usr/bin/awk '{print $3}' >> /tmp/status
cat srvoff | /usr/bin/grep -i 'DIPoller' | /usr/bin/awk '{print $4}' >> /tmp/status

set new = `cat /tmp/status`
set new = ( $new )
rm /tmp/status

if ( "$new[1]" =~ Active && "$new[2]" =~ Active && "$new[3]" =~ Active && "$new[4]" =~ Active && "$new[5]" =~ Active) then
    exit 110
else if (  "$new[1]" =~ NOT && "$new[2]" =~ NOT && "$new[3]" =~ NOT && "$new[4]" =~ NOT && "$new[5]" =~ NOT ) then
   exit 100
else
   exit 1


Last edited by Scrutinizer; 04-25-2012 at 07:42 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

accessing my first element of array

Hello everyonel, I have an array set like so num=4 read name arr=name I go through while loop to assign different values to different array element from 1 to 4. when I try to access the FIRST element of the array I get the last one first. Like if I say ${arr} it will show the last element... (4 Replies)
Discussion started by: afadaghi
4 Replies

2. Shell Programming and Scripting

Shift array element

I want to delete and 0th element of array in shell scrpit and also shift all others to one level up. (2 Replies)
Discussion started by: darshakraut
2 Replies

3. Shell Programming and Scripting

HELP unsetting array element in loop

I have a loop and I need to be able to unset the array element that I am currently accessing in it. I was thinking of making a counter that increments with the loop and doing unset $dirs but if I do that I am not sure if the other members of the array would get shifted down in index (meaning that... (2 Replies)
Discussion started by: msf5042
2 Replies

4. Shell Programming and Scripting

remove an element from array

I need to remove an element from the below array variable TABLENAME. #!/bin/ksh set -A TABLENAME "mirf roxar keke mirs" echo "the array is ${TABLENAME}" If i need to remove say keke and have the final TABLENAME as below, how this could be achieved. Pls throw some light. echo "Modified... (3 Replies)
Discussion started by: michaelrozar17
3 Replies

5. Shell Programming and Scripting

How to assign an array element to a variable

Hi every one.. I'm new to shell scripting... I would like to assign a single array element to a variable... Is it possible to do it.... Could any body help me.... (3 Replies)
Discussion started by: kaushik_87
3 Replies

6. Shell Programming and Scripting

previous element in the array perl

Hi, How to get previous/next element in the array perl Example @queue = (1, 2 ,3 , 4); I want to get value of 1 and 2, or, 2 and 3, or 3 and 4...etc and compare to value which one is greater to do that I need to get previous and next element of array ? (1 Reply)
Discussion started by: guidely
1 Replies

7. Shell Programming and Scripting

Multiplying array element

I am trying to take all the elements of an array and multiply them by 2, and then copy them to a new array. Here is what I have i=0 for true in DMGLIST do let DMGSIZES2="${DMGSIZES}"*2 let i++ done unset i echo ${DMGSIZES2} It does the calculation correctly for the first element,... (7 Replies)
Discussion started by: nextyoyoma
7 Replies

8. Shell Programming and Scripting

ksh insert element in array

Hi all, I need help with the following scenario in ksh. If the number of elements contained by arrayA is 11 I need to insert a zero as the element arrayA then print all arrayA elements separated by comma. Appreciate your help. (9 Replies)
Discussion started by: ejianu
9 Replies

9. Shell Programming and Scripting

How to insert an array element within regex?

Hello to all, I'm trying to separate the string "str" using a regex within match function. The substrings that I want to separate, begin with 22, 23, 24 or 25 and followed by 12 or 14 characters. And I want to replace 22 with MJS, 23 with UYT, 24 with WER and 25 with PIL. For this string... (4 Replies)
Discussion started by: Ophiuchus
4 Replies

10. UNIX for Advanced & Expert Users

Array Element

This question is for someone that's more familiar with Array Element. I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024? param_array="$param_nam" counter=$counter+1 #to avoid space... (3 Replies)
Discussion started by: cumeh1624
3 Replies
PDF::API2::Basic::PDF::Filter(3pm)			User Contributed Perl Documentation			PDF::API2::Basic::PDF::Filter(3pm)

NAME
PDF::API2::Basic::PDF::Filter - Abstract superclass for PDF stream filters SYNOPSIS
$f = PDF::API2::Basic::PDF::Filter->new; $str = $f->outfilt($str, 1); print OUTFILE $str; while (read(INFILE, $dat, 4096)) { $store .= $f->infilt($dat, 0); } $store .= $f->infilt("", 1); DESCRIPTION
A Filter object contains state information for the process of outputting and inputting data through the filter. The precise state information stored is up to the particular filter and may range from nothing to whole objects created and destroyed. Each filter stores different state information for input and output and thus may handle one input filtering process and one output filtering process at the same time. METHODS
PDF::API2::Basic::PDF::Filter->new Creates a new filter object with empty state information ready for processing data both input and output. $dat = $f->infilt($str, $isend) Filters from output to input the data. Notice that $isend == 0 implies that there is more data to come and so following it $f may contain state information (usually due to the break-off point of $str not being tidy). Subsequent calls will incorporate this stored state information. $isend == 1 implies that there is no more data to follow. The final state of $f will be that the state information is empty. Error messages are most likely to occur here since if there is required state information to be stored following this data, then that would imply an error in the data. $str = $f->outfilt($dat, $isend) Filter stored data ready for output. Parallels "infilt". NAME
PDF::API2::Basic::PDF::ASCII85Decode - Ascii85 filter for PDF streams. Inherits from PDF::API2::Basic::PDF::Filter NAME
PDF::API2::Basic::PDF::RunLengthDecode - Run Length encoding filter for PDF streams. Inherits from PDF::API2::Basic::PDF::Filter NAME
PDF::API2::Basic::PDF::ASCIIHexDecode - Ascii Hex encoding (very inefficient) for PDF streams. Inherits from PDF::API2::Basic::PDF::Filter perl v5.14.2 2011-03-10 PDF::API2::Basic::PDF::Filter(3pm)
All times are GMT -4. The time now is 02:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy