Sponsored Content
Top Forums Shell Programming and Scripting [Solved] If doesn't evaluate the first test Post 302746025 by jimm on Tuesday 18th of December 2012 04:03:12 PM
Old 12-18-2012
[Solved] If doesn't evaluate the first test

Good afternoon,
I am tearing hair out over this. It should be so simple. I have an if statement to evaluate whether or not replication is working. I am testing variables from mysql to see if they are both "Yes". I have put some echo statements in to see how far the code proceeds. It always seems to skip the initial test (or evaluate it as false) and run to the end of the script. I could really use another pair of eyes on this.
Thanks
Jim

Code:
#!/bin/bash

# variables
host="ipaddr"
user="user"
pass="password"
var="Yes"

#Connect
out=$(mysql -h $host -u$user -p$pass -se "show slave status")
echo $out > /tmp/working.txt
awk '{print$11, $12, $16, $17, $19, $20}' /tmp/working.txt >> /tmp/variables
rm -f /tmp/working.txt
read log pos io sql error query < /tmp/variables

echo $io $sql

if [$io = "Yes" -a $sql = $var]; then
rm -f /tmp/variables
echo "made 1"
        else
mail -s "replication broke" email@gmail.com < /tmp/variables
echo "hit 2"
fi
rm -f /tmp/variables
echo "done"


Last edited by jimm; 12-19-2012 at 09:43 AM.. Reason: solved
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

2. Programming

Kernel module - How to test if file doesn't exist

Hey, I'm currently getting into some kernel module progamming. As a little exercise I want to read the headers out of an ELF file. My code is very simple, here is the important part: struct file *fp; /* ... */ fp = filp_open("some/file/on/my/pc", O_RDONLY, 0); if(fp == NULL) { ... (15 Replies)
Discussion started by: disaster
15 Replies

3. Shell Programming and Scripting

[Solved] Bash test 2 variables to see if ones greater by n

Experts, I have a bash shell script that generates 2 variables that have the current minute and a minute from a log file. Can someone please show me the best way to test if the minutes stray by 5. So basically if: This is ok: Last Fitting Min ============= 02 Current Minute =============... (2 Replies)
Discussion started by: jaysunn
2 Replies

4. Shell Programming and Scripting

Value of variable is NULL, but test doesn't seem to recognize

Hello, Unix-forums! My problem: read -p "Enter any number, please" number sleep 1 echo $number | tr -d 0-9 test -z $number && echo "Thank you" || echo "This is not a number"Test always displays "This is not a number". It doesn't matter if I entered a or 1. But if I order echo... (2 Replies)
Discussion started by: intelinside
2 Replies

5. Shell Programming and Scripting

[Solved] BASH - chaining TEST and COMMAND with && and II

Can you explain what this line of script is doing. What I have understood is : -- variable C is the name of a software which is either not installed, so it must be installed or allready installed and then should be update if newer version found -- branch B="$B $C" is to install the software --... (4 Replies)
Discussion started by: jcdole
4 Replies

6. Shell Programming and Scripting

[Solved] Script doesn't work..help?

hi, i am trying to run this script.the name of script is final.sh after i run it: #./final.sh & i grep the command # ps -a | grep bash and i see more then one processes runing 3!! Please use code tags how can i solve this problem? my target script must always run in... (8 Replies)
Discussion started by: zigizag
8 Replies

7. UNIX for Dummies Questions & Answers

[Solved]Can anyone tell me why -H flag with sudo doesn't switch to the target user's home directory?

I have checked the man page ,which says : The -H (HOME) option sets the HOME environment variable to the homedir of the target user (root by default) as specified in passwd(5). By default, sudo does not modify HOME But I have tried below command: #... (1 Reply)
Discussion started by: Michaelw321
1 Replies

8. Shell Programming and Scripting

[solved] awk: test assoc. array for content

Hi all, I am looking for a quick/short way in awk to check if an associative array has any content. I know I can split() it to an indexed array and check if the 1st element is set, or cycle through it with something like for( ele in arr ), but I want to avoid that, as I am looking for a shorter... (3 Replies)
Discussion started by: zaxxon
3 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Custom actions in Thunar doesn't display at all.

I have came across a few websites stating some custom actions for Thunar - crunchbang ubuntu I tried inputting the stated commands to Thunar, but it doesn't display at all in mine. I tried "gksu thunar %f" ( Opens current folder with root permissions.) , but when I right click in a... (0 Replies)
Discussion started by: Hijanoqu
0 Replies

10. Shell Programming and Scripting

How to test that a string doesn't contain specific characters?

Hi ! :) I made this : #!/bin/bash rsa_dir="/etc/openvpn/easy-rsa/" rsa_key_dir="/etc/openvpn/easy-rsa/keys/" ccd_dir="/etc/openvpn/ccd/" regex_special_char='' cd $rsa_dir while read -p "Please can you enter the vpn's username : " username ] || ] || ] || ] do echo "Your entry... (10 Replies)
Discussion started by: Arnaudh78
10 Replies
OCF_HEARTBEAT_MYSQL(7)						OCF resource agents					    OCF_HEARTBEAT_MYSQL(7)

NAME
ocf_heartbeat_mysql - Manages a MySQL database instance SYNOPSIS
mysql [start | stop | status | monitor | promote | demote | meta-data | validate-all] DESCRIPTION
Resource script for MySQL. May manage a standalone MySQL database, a clone set with externally managed replication, or a complete master/slave replication setup. While managing replication, the default behavior is to use uname -n values in the change master to command. Other IPs can be specified manually by adding a node attribute ${INSTANCE_ATTR_NAME}_mysql_master_IP giving the IP to use for replication. For example, if the mysql primitive you are using is p_mysql, the attribute to set will be p_mysql_mysql_master_IP. SUPPORTED PARAMETERS
binary Location of the MySQL server binary (optional, string, default "/usr/bin/safe_mysqld") client_binary Location of the MySQL client binary (optional, string, default "mysql") config Configuration file (optional, string, default "/etc/my.cnf") datadir Directory containing databases (optional, string, default "/var/lib/mysql") user User running MySQL daemon (optional, string, default "mysql") group Group running MySQL daemon (for logfile and directory permissions) (optional, string, default "mysql") log The logfile to be used for mysqld. (optional, string, default "/var/log/mysqld.log") pid The pidfile to be used for mysqld. (optional, string, default "/var/run/mysql/mysqld.pid") socket The socket to be used for mysqld. (optional, string, default "/var/lib/mysql/mysql.sock") test_table Table to be tested in monitor statement (in database.table notation) (optional, string, default "mysql.user") test_user MySQL test user, must have select privilege on test_table (optional, string, default "root") test_passwd MySQL test user password (optional, string, no default) enable_creation If the MySQL database does not exist, it will be created (optional, boolean, default 0) additional_parameters Additional parameters which are passed to the mysqld on startup. (e.g. --skip-external-locking or --skip-grant-tables) (optional, string, no default) replication_user MySQL replication user. This user is used for starting and stopping MySQL replication, for setting and resetting the master host, and for setting and unsetting read-only mode. Because of that, this user must have SUPER, REPLICATION SLAVE, REPLICATION CLIENT, and PROCESS privileges on all nodes within the cluster. Mandatory if you define a master-slave resource. (optional, string, no default) replication_passwd MySQL replication password. Used for replication client and slave. Mandatory if you define a master-slave resource. (optional, string, no default) replication_port The port on which the Master MySQL instance is listening. (optional, string, default "3306") max_slave_lag The maximum number of seconds a replication slave is allowed to lag behind its master. Do not set this to zero. What the cluster manager does in case a slave exceeds this maximum lag is determined by the evict_outdated_slaves parameter. (optional, integer, default 3600) evict_outdated_slaves If set to true, any slave which is more than max_slave_lag seconds behind the master has its MySQL instance shut down. If this parameter is set to false in a primitive or clone resource, it is simply ignored. If set to false in a master/slave resource, then exceeding the maximum slave lag will merely push down the master preference so the lagging slave is never promoted to the new master. (optional, boolean, default false) reader_attribute An attribute that the RA can manage to specify whether a node can be read from. This node attribute will be 1 if it's fine to read from the node, and 0 otherwise (for example, when a slave has lagged too far behind the master). A typical example for the use of this attribute would be to tie a set of IP addresses to MySQL slaves that can be read from. This parameter is only meaningful in master/slave set configurations. (unique, optional, string, default "readable") SUPPORTED ACTIONS
This resource agent supports the following actions (operations): start Starts the resource. Suggested minimum timeout: 120. stop Stops the resource. Suggested minimum timeout: 120. status Performs a status check. Suggested minimum timeout: 60. monitor Performs a detailed status check. Suggested minimum timeout: 30. Suggested interval: 20. monitor (Master role) Performs a detailed status check. Suggested minimum timeout: 30. Suggested interval: 10. monitor (Slave role) Performs a detailed status check. Suggested minimum timeout: 30. Suggested interval: 30. promote Promotes the resource to the Master role. Suggested minimum timeout: 120. demote Demotes the resource to the Slave role. Suggested minimum timeout: 120. notify Suggested minimum timeout: 90. validate-all Performs a validation of the resource configuration. Suggested minimum timeout: 5. meta-data Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5. EXAMPLE
The following is an example configuration for a mysql resource using the crm(8) shell: primitive p_mysql ocf:heartbeat:mysql op monitor depth="0" timeout="30" interval="20" op monitor role="Master" depth="0" timeout="30" interval="10" op monitor role="Slave" depth="0" timeout="30" interval="30" ms ms_mysql p_mysql meta notify="true" interleave="true" SEE ALSO
http://www.linux-ha.org/wiki/mysql_(resource_agent) AUTHOR
Linux-HA contributors (see the resource agent source for information about individual authors) resource-agents UNKNOWN 06/09/2014 OCF_HEARTBEAT_MYSQL(7)
All times are GMT -4. The time now is 07:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy