Sponsored Content
Top Forums Shell Programming and Scripting How do you use pull data from multiple lines to do a for statement? Post 302384890 by scottzx7rr on Wednesday 6th of January 2010 02:56:25 PM
Old 01-06-2010
How do you use pull data from multiple lines to do a for statement?

Guys I am having a problem with being able to find missing monitors in a configuration check script I am trying to create for accountability purposes for managing a large number of systems. What I am trying to do is run a script that will look at the raw config data in a file and pull all the pool entries that doesn't have a monitor assigned in it. So that I can fix that error. The file that I am pulling has a ton of information but I am only worried about the pool information so I have made a script that pulls only that needed information into a new file to make it easier to work against. Here is the output of Config Data from that script:
Code:
pool Happy1 {
   monitor all happy1-check
   members
      1.1.1.4:https
}
pool Happy2 {
   members
      1.1.2.4:https
}
pool Happy3 {
   monitor all happy3-check
   members
      1.1.3.4:https
}
pool Happy4 {
   members
      1.1.4.4:https
}
pool Happy5 {
   monitor all happy5-check
   members
      1.1.5.4:https
}

I am having a hard time being able to pull the data from multiple lines to a single line entry as exampled below is what I am looking for since there is no monitor listed in the config entrry for each pool:
Code:
-------------------------------------------------------------------------
| Checking for Pools not being monitored...
|
|   Pool Happy2 may not being monitored
|   Pool Happy4 may not being monitored
|
-------------------------------------------------------------------------

Here is what I was using for the older version that was only on a single line so it made it much easier to do the search.

Code:
TMPDIR="/var/tmp/monitor"
cd ${TMPDIR}
cd - > /dev/null
CONF1=${TMPDIR}/config/test.txt
echo "-------------------------------------------------------------------------"
echo "| Checking for Pools not being monitored..."
echo "|"
pool=`grep -i "^pool" ${CONF1} | cut -f2 -d" "`
for i in $pool; do
   monitorcheck=`grep "monitor" ${CONF1}`
   [ "${monitorcheck}" = "" ] || echo "|   Pool $i may not being monitored."
done
echo ${monitorcheck}
echo "|"
echo "-------------------------------------------------------------------------"


Last edited by Scott; 01-06-2010 at 03:59 PM.. Reason: Code tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Split data into multiple lines

All, I have a requirement where I will need to split a line into multiple lines. Ex: Input: 2ABCDEFGH2POIYUY2ASDGGF2QWERTY Output: 2ABCDEFGH 2POIYUY 2ASDGGF 2QWERTY The data is of no fixed lenght. Only the lines have to start with 2. How can this be done. (5 Replies)
Discussion started by: kingofprussia
5 Replies

2. Shell Programming and Scripting

(sed) parsing insert statement column that crosses multiple lines

I have a file with a set of insert statements some of which have a single column value that crosses multiple lines causing the statement to fail in sql*plue. Can someone help me with a sed script to replace the new lines with chr(10)? here is an example: insert into mytable(id, field1, field2)... (3 Replies)
Discussion started by: jjordan
3 Replies

3. Shell Programming and Scripting

Outputting data from multiple lines

Hi guys, looking for a bit of advise, and as I am a complete novice, please excuse the daft questions!! I have a list of events and of which entry looks like this; # # Event 1 # NAME = Event 1 # 12345 : 123 : 1 : 1 : L,1,N : 1,0 : Event # # Event 2 # NAME = Event 2 # 12346... (8 Replies)
Discussion started by: JayC89
8 Replies

4. Shell Programming and Scripting

multiple lines inside a case statement

echo "please enter ur choice.. 1. Make a file. 2. Display contents 3. Copy the file 4. Rename the file 5. Delete the file 6. Exit" read choice case $choice in 1 ) echo enter the file name read fname if then echo... (2 Replies)
Discussion started by: gotam
2 Replies

5. UNIX for Dummies Questions & Answers

Pull out multiple lines with grep patternfile

Hi, I'm trying to get lines from a file using identifiers in the first two columns. I have used: cat MasterFile.txt | grep -f Pattern.txt and the lines I want display on screen. If I try to put them in a file the file is created but stays empty: cat MasterFile.txt | grep -f Pattern.txt... (14 Replies)
Discussion started by: FGPonce
14 Replies

6. Shell Programming and Scripting

Extracting data from multiple lines

Hi All, I am stuck in one step.. I have one file named file.txt having content: And SGMT.perd_id = (SELECT cal.fiscal_perd_id FROM $ODS_TARGT.TIM_DT_CAL_D CAL FROM $ODS_TARGT.GL_COA_SEGMNT_XREF_A SGMT SGMT.COA_XREF_TYP_IDN In (SEL COA_XREF_TYP_IDN From... (4 Replies)
Discussion started by: Shilpi Gupta
4 Replies

7. Shell Programming and Scripting

How do I use grep to pull incremental data and send to multiple files?

Hi Everyone, Im currently using the below code to pull data from a large CSV file and put it into smaller files with just the data associated with the number that I "grep". grep 'M053' test.csv > test053.csv Is there a way that I can use grep to run through my file like the example below... (6 Replies)
Discussion started by: TheStruggle
6 Replies

8. Shell Programming and Scripting

Split data into multiple lines

Hi, if i have data like below: Control|AC-00011-CN-2475208 AC-00011-CN-2475211 AC-00007-CN-2475238 AC-00007-CN-2475241 Im getting output in required format as below Control|AC-00011-CN-2475208 Control|AC-00011-CN-2475211 Control|AC-00007-CN-2475238 Control|AC-00007-CN-2475241 using awk... (9 Replies)
Discussion started by: JSKOBS
9 Replies

9. UNIX for Beginners Questions & Answers

Multiple lines of data?

I use this to get 8 random letters: cat /dev/urandom | tr -dc 'A-Z' | fold -w 8 | head -n 1 Result is, WLGFJFZY What I'm trying to do is get 10 lines of random letters, separated by a line and each block having ascending numbers i.e; 00 IWMTDFIM 01 KZZZCHPQ 02 YBTGFHGT 03 (4 Replies)
Discussion started by: jenny-mac
4 Replies
asadmin-delete-jdbc-connection-pool(1AS)			   User Commands			  asadmin-delete-jdbc-connection-pool(1AS)

NAME
delete-jdbc-connection-pool - removes the JDBC connection pool SYNOPSIS
delete-jdbc-connection-pool --user admin_user [--password admin_password] [--host localhost] [--port 4848] [--secure|-s] [--passwordfile filename] [--terse=false] [--echo=false] [--interactive] [--cascade=false] connection_pool_ID Removes the JDBC connection pool. This command is supported in remote mode only. OPTIONS
--user authorized domain application server administrative username. --password password to administer the domain application server. --host machine name where the domain application server is running. --port port number of the domain application server listening for administration requests. --secure if true, uses SSL/TLS to communicate with the domain application server. --passwordfile file containing the domain application server password. --terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well- formatted data for consumption by a script. --echo setting to true will echo the command line statement on the standard output. --interactive prompts you for the required options that are not already specified. --cascade If set to true, deletes all the connector resources associated with the pool, apart from the pool itself. If set to false (default), the deletion of the pool fails if there are any resources associated with the pool. Either the resource has to be deleted explicitly, or set the option to true. OPERANDS
connection_pool_id name of the JDBC connection pool to be deleted. Example 1: Using the delete-jdbc-connection-pool command asadmin> delete-jdbc-connection-pool --user admin --password adminadmin --host fuyako port 7070 XA_connection_pool Deleted the JDBC connection pool resource with id = XA_connection_pool Where: the XA_connection_pool resource is deleted. EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-create-jdbc-connection-pool(1AS), asadmin-list-jdbc-connection-pools(1AS) J2EE 1.4 SDK March 2004 asadmin-delete-jdbc-connection-pool(1AS)
All times are GMT -4. The time now is 09:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy