Help with shell script to compare values between servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with shell script to compare values between servers
# 1  
Old 11-15-2014
Question Help with shell script to compare values between servers

Hi

I am a beginner in UNIX and shell scripting and i have a requirement as stated below,

requirement


Login to a unix server 1

1. connect to a database mysql -uUsername -pPassword
2. Select a Schema : "Use Schemaname1"
3. query for a particular record
select cycle_id from DBName where xyz>'execution_date' and cycle_type='xyz';



Note: execution_date= date of execution in YYYY/MM/DD format.

4. Change the schema to SchemaName2; Use SchemaName2;
5. execute the query
select count(*) from DBName where cycle_id='xxxx';

Login to another server 2

6. Connect to a database mysql -uUsername -pPassword
7. select count(*) from modem_core_top_source where cycle_id='xxxx';

cycle_id should be the latest cycle_id noted from p table in step 3.

8. Match the count step 5 = step 7

I got the values from server 1 and stored it in a variable , but how to connect to server 2 ( i tried using sftp , but i am prompted for a password )

Can you guys please help me on this SmilieSmilieSmilie
# 2  
Old 11-15-2014
If this is homework, there are some requirements you need to fill out and you must post in the Homework & Coursework Questions

If this is not homework, you must show what you have tried to accomplish the tasks, where you are having problems with, some representative example of the work done so far, and it would be helpful if you post a sample of the errors you are getting.
Desired output is only required once you show the efforts on your part.

Welcome to the forum.
# 3  
Old 11-15-2014
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

2. UNIX for Dummies Questions & Answers

How to compare to values returned from sql in shell scripting?

hey i am using this code to connect to sql , store the value in variable and then compare it with another variable after some time by executing the same query but the desired result is not coming #!/bin/bash val=$(sqlplus -s rte/rted2@rel76d2 <<ENDOFSQL set heading off set feedback off... (11 Replies)
Discussion started by: ramsavi
11 Replies

3. Shell Programming and Scripting

LINUX - How to compare the values in 2 files & exit from the script

Hi All, I have a requirement where I need to compare 2 files & if the values in the files match, it should proceed, else exit the script without proceeding further. For e.g : Scenario 1 In this case, the script should exit without proceeding further. Scenario 2 In this case, the script... (7 Replies)
Discussion started by: dsfreddie
7 Replies

4. Shell Programming and Scripting

Compare values for a pattern match and execute script

Here in the input file 23:59:13,devicename,21,server1,700 23:59:13,devicename,22,server2,200 23:59:13,devicename,23,server3,200 23:59:13,devicename,24,server4,200 23:59:13,devicename,25,server5,200 23:59:13,devicename,26,server6,200 23:59:13,devicename,27,server7,200... (6 Replies)
Discussion started by: necro98
6 Replies

5. Shell Programming and Scripting

How to compare version values in shell script?

Hi, I need to compare two versions values and report only true or false depending on their difference result. like - echo $(echo "1.8 >= 2.0" | bc) 0 echo $(echo "2.0 >= 2.0" | bc) 1 but my task is to compare values like - echo $(echo "1.9.1 >= 2.0" | bc) (standard_in) 1: syntax... (3 Replies)
Discussion started by: abhitanshu
3 Replies

6. Shell Programming and Scripting

Shell script to run command + compare values and post a warning message.

Hi all, I am trying to create shell script to run command then compare values with rule set for every 5 seconds and post a warning message if the compared value meet the rules. -the script is related to Oracle/Sun product messaging server 6.2 1) command that need to be run to gather... (2 Replies)
Discussion started by: Mr_47
2 Replies

7. UNIX for Dummies Questions & Answers

compare decimal and integer values in if in bash shell

i need to do camparisions like the below. For the case when first=10 and second=9.9 the scripts displays process failed. I need to be able to convert the values to integer before doing the comparision. Like 9.9 should be rounded over to 10 before doing comparision. Please advice how can... (3 Replies)
Discussion started by: nehagupta
3 Replies

8. Shell Programming and Scripting

open 2 files and compare values script - urgent

Hi gurus I have two csv files that are outputs. The file contains data similar to s.no,number1,number2,date1 -------------------------------- 1, a123,482.29,11/28/07 13:00 2,a124,602.7,9/24/07 14:00 3,a125,266.93,10/9/07 16.48 4,a126,785.15,11/14/07 16:08 <file 2> s.no name... (2 Replies)
Discussion started by: inkyponky
2 Replies

9. Shell Programming and Scripting

Script to compare all the config files in a cluster of servers.

Hello Lads! Climbing the shell scripting learning curve, i am faced with yet another obstacle! Here's the challenge in front of me : 1) I have 15 servers in a cluster,all of them have the same config files by name : /home/apps/xrm/App_B.cfg 2) The developers change the entries in the... (5 Replies)
Discussion started by: rdlover
5 Replies

10. Shell Programming and Scripting

Need a sheel script to compare no of file on diffrent servers

i have serverA and serverB and i have a folder with same name an location in both servers.... Now i want to compare files in folder(serverA) with folder (serverB) if there are files missing in folderB then copy those files from folder(serverA) to folder(serverB) (1 Reply)
Discussion started by: ashahzad
1 Replies
Login or Register to Ask a Question