Sponsored Content
Top Forums Shell Programming and Scripting Report a missing property and property value mis match script. Post 302549655 by Corona688 on Tuesday 23rd of August 2011 02:51:04 PM
Old 08-23-2011
Code:
awk -v MASTER="/path/to/master.file" -v FS="=" 'BEGIN {
        while(getline <MASTER)
        {
                if ( ($0 ~ /^[ \t]*#/) || ($0 == "") ) continue;

                if($2 != "")
                        SET[$1]=$2
        }
}

{
        if (!($0 ~ /^[ \t]*#/) && !($0 == "") )
        if(SET[$1] && (SET[$1] != $2))
                print "ERROR " $0;
}' < /path/to/local.file

---------- Post updated at 12:51 PM ---------- Previous update was at 12:34 PM ----------

Improved version:
Code:
awk -v FS="=" -v MASTER="/path/to/master" 'BEGIN { while(getline <MASTER)
        {
                if (($0 ~ /^[ \t]*#/) || ($0 == "")) continue;
                INMASTER[$1]=1;         VAL[$1]=$2;
        }
}

{       if (!($0 ~ /^[ \t]*#/) && !($0 == "") ) LOCAL[$1]=$2;   }

END {   for(k in INMASTER)
        {
                if((VAL[k] == "") && (LOCAL[k] == ""))  print "UNSET " k;
                if((VAL[k]!="") && (LOCAL[k] != VAL[k])) print "OVERRIDDE " k;
        }
}' < /path/to/local

With your input data, and db.port.2=1521 modified to 1522, I get:

Code:
UNSET jboss.proxy.name
OVERRIDDE db.port.2

This User Gave Thanks to Corona688 For This Post:
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem printing the property of xml file via shell script

Hi, I have a config.xml which cointains the tags like <CONFIG> <PROPERTY name="port" value="1111"/> <PROPERTY name="dbname" value="ABCDE"/> <PROPERTY name="connectstring" value="xyz/pwd"/> </CONFIG> This file is in some directory at UNix box. I need to write a... (4 Replies)
Discussion started by: neeto
4 Replies

2. Shell Programming and Scripting

source a property file in script give error

I have sourced a property file in my script like this to load some variables in the script Then i am able to echo all the property file values inside script but the script is not able to recognize other unix commands #!/bin/bash . build.properties mkdir build i am getting error ... (3 Replies)
Discussion started by: codeman007
3 Replies

3. Shell Programming and Scripting

URGENT: Script/Function needed to read text property files in block wise

Hi, Iam in a need for a script/function in KSH where I want to read a text file (property file) in block by block. Here is the example: Heading Name Descripton Block Block1 Value1 Description Property Name Value Property Name Value Property Name Value Property Name Value Property Name... (7 Replies)
Discussion started by: ysreenivas
7 Replies

4. Shell Programming and Scripting

Script to update Property Entry Values

Hi All, I'm Raghavendra. I have a very urgent requirement to develop a Shell Script which will allow to use variables in a property file as demonstarted below var1=UNIX var2=LINUX var3=WINDOWS var4=$var1,$var2 var5=$var3 Could you please help me to develop a shell script which can... (2 Replies)
Discussion started by: raghavstunner
2 Replies

5. Shell Programming and Scripting

To read xml value depending on property

Hi have some xml like this <example> <Cell Name="Cell1" ConfigureHost="claas" Role="APPSERV,BACKEND"> <Node Name="aaaaa" Role="APPSERV,BACKEND,CLM"/> <Node Name="vvvv" Role="APPSERV,BACKEND"/> <Mercury Type="default" FQDN="ssssss" PrimaryReturnFQDN=""/> </Cell> ... (1 Reply)
Discussion started by: javaholics
1 Replies

6. Shell Programming and Scripting

Reading a property file through shell script???

Hi! i need a script that can read a property file. i.e., A script to read a "property" from property file. Read the property value and based on value of property, decide whether to start the some dataload activity or not. Its urngent. Can anyone help me out???:( (7 Replies)
Discussion started by: sukhdip
7 Replies

7. Shell Programming and Scripting

Not to remove Files based on property value

Hi All, Need your help to fix one script. Main agenda is: 1. Read a property file. 2. Delete all files in directory except the name from Property file. I am trying to read property file for value then deleting all files from directory except THAT value/name. I have tried so far as... (3 Replies)
Discussion started by: sukhdip
3 Replies
MYSQLRPLSHOW(1) 						  MySQL Utilities						   MYSQLRPLSHOW(1)

NAME
mysqlrplshow - Show slaves attached to a master SYNOPSIS
mysqlrplshow [options] DESCRIPTION
This utility shows the replication slaves for a master. It prints a graph of the master and its slaves labeling each with the host name and port number. To explore the slaves for each client, use the --recurse option. This causes the utility to connect to each slave found and attempt to determine whether it has any slaves. If slaves are found, the process continues until the slave is found in the list of servers serving as masters (a circular topology). The graph displays the topology with successive indents. A notation is made for circular topologies. If you use the --recurse option, the utility attempts to connect to the slaves using the user name and password provided for the master. By default, if the connection attempt fails, the utility throws an error and stops. To change this behavior, use the --prompt option, which permits the utility to prompt for the user name and password for each slave that fails to connect. You can also use the --num-retries=n option to reattempt a failed connection 'n' times before the utility fails. An example graph for a typical topology with relay slaves is shown here: # Replication Topology Graph:: localhost:3311 (MASTER) | +--- localhost:3310 - (SLAVE) | +--- localhost:3312 - (SLAVE + MASTER) | +--- localhost:3313 - (SLAVE) MASTER, SLAVE, and SLAVE + MASTER indicate that a server is a master only, slave only, and both slave and master, respectively. A circular replication topology is shown like this, where <--> indicates circularity: # Replication Topology Graph localhost:3311 (MASTER) | +--- localhost:3312 - (SLAVE + MASTER) | +--- localhost:3313 - (SLAVE + MASTER) | +--- localhost:3311 <--> (SLAVE) To produce a column list in addition to the graph, specify the --show-list option. In this case, to specify how to display the list, use one of the following values with the --format option: grid (default) Display output in grid or table format like that of the mysql monitor. csv Display output in comma-separated values format. tab Display output in tab-separated format. vertical Display output in single-column format like that of the G command for the mysql monitor. The utility uses of the SHOW SLAVE HOSTS statement to determine which slaves the master has. If you want to use the --recurse option, slaves should have been started with the --report-host and --report-port options set to their actual host name and port number or the util- ity may not be able to connect to the slaves to determine their own slaves. OPTIONS
mysqlrplshow accepts the following command-line options: --help Display a help message and exit. --format=<format>, -f<format> Specify the display format for column list output. Permitted format values are grid, csv, tab, and vertical. The default is grid. This option applies only if --show-list is given. --master=<source> Connection information for the master server in <user>[:<passwd>]@<host>[:<port>][:<socket>] format. --max-depth=<N> The maximum recursion depth. This option is valid only if --recurse is given. --num-retries=<num_retries>, -n<num_retries> The number of retries permitted for failed slave login attempts. This option is valid only if --prompt is given. --prompt, -p Prompt for the slave user and password if different from the master user and password. If you give this option, the utility sets --num-retries to 1 if that option is not set explicitly. This ensures at least one attempt to retry and prompt for the user name and password should a connection fail. --quiet, -q Turn off all messages for quiet execution. This option does not suppress errors or warnings. --recurse, -r Traverse the list of slaves to find additional master/slave connections. User this option to map a replication topology. --show-list, -l Display a column list of the topology. --version Display version information and exit. NOTES
The login user must have the REPLICATE SLAVE and REPLICATE CLIENT privileges to successfully execute this utility. Specifically, the login user must have appropriate permissions to execute SHOW SLAVE STATUS, SHOW MASTER STATUS, and SHOW SLAVE HOSTS. For the --format option, the permitted values are not case sensitive. In addition, values may be specified as any unambiguous prefix of a valid value. For example, --format=g specifies the grid format. An error occurs if a prefix matches more than one valid value. EXAMPLES
To show the slaves for a master running on port 3311 on the local host, use the following command: $ mysqlrplshow --master=root@localhost:3311 # master on localhost: ... connected. # Finding slaves for master: localhost:3311 # Replication Topology Graph localhost:3311 (MASTER) | +--- localhost:3310 - (SLAVE) | +--- localhost:3312 - (SLAVE) As shown in the example, you must provide valid login information for the master. To show the full replication topology of a master running on the local host, use the following command: $ mysqlrplshow --master=root@localhost:3311 --recurse # master on localhost: ... connected. # Finding slaves for master: localhost:3311 # Replication Topology Graph localhost:3311 (MASTER) | +--- localhost:3310 - (SLAVE) | +--- localhost:3312 - (SLAVE + MASTER) | +--- localhost:3313 - (SLAVE) To show the full replication topology of a master running on the local host, prompting for the user name and password for slaves that do not have the same user name and password credentials as the master, use the following command: $ mysqlrplshow --recurse --prompt --num-retries=1 --master=root@localhost:3331 Server localhost:3331 is running on localhost. # master on localhost: ... connected. # Finding slaves for master: localhost:3331 Server localhost:3332 is running on localhost. # master on localhost: ... FAILED. Connection to localhost:3332 has failed. Please enter the following information to connect to this server. User name: root Password: # master on localhost: ... connected. # Finding slaves for master: localhost:3332 Server localhost:3333 is running on localhost. # master on localhost: ... FAILED. Connection to localhost:3333 has failed. Please enter the following information to connect to this server. User name: root Password: # master on localhost: ... connected. # Finding slaves for master: localhost:3333 Server localhost:3334 is running on localhost. # master on localhost: ... FAILED. Connection to localhost:3334 has failed. Please enter the following information to connect to this server. User name: root Password: # master on localhost: ... connected. # Finding slaves for master: localhost:3334 # Replication Topology Graph localhost:3331 (MASTER) | +--- localhost:3332 - (SLAVE) | +--- localhost:3333 - (SLAVE + MASTER) | +--- localhost:3334 - (SLAVE) COPYRIGHT
Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA AUTHOR
MySQL Utilities Team COPYRIGHT
2010, Oracle and/or its affiliates. All rights reserved. 1.0.3 May 09, 2012 MYSQLRPLSHOW(1)
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy