How to Create LOG and Validate for this Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Create LOG and Validate for this Script
# 8  
Old 10-05-2011
Could you show what your script actually is, then?
# 9  
Old 10-06-2011
Code:
#!/bin/bash
current_date=`date +%d-%m-%Y_%H.%M.%S`
Today=`date +%d%m%Y`
Lfriday=`date +%d%m%Y -d last-friday`
RootPath=/var/domaincount/com
ch=domaincount
LOG=/var/tmp/Intelliscanlog/com/comcount$current_date.log

echo Intelliscan Process started for .COM TLD $current_date >> $LOG

#################################################################################################
 Using Wget Downloading the Zone files it will try only one time
if ! wget --tries=1 --ftp-user=USERNAME --ftp-password=PASSWORD ftp://ftp.URL/zone.gz

#then
 #  echo Download Not Success .COM Domain count Failed With Error >> $LOG
  # exit 1
#fi
###The downloaded file in Gunzip format from that we need to unzip and start the domain count process####

gunzip com.zone.gz

mv com.zone $RootPath/$Today.com

cd /var

chown -R mysql:mysql $ch

cd $RootPath

###### It will start the Count ####ootPatH
mysql zonefile<<EOFMYSQL || echo "query failed" >> $LOG
CREATE TABLE com$Today(domain VARCHA(255),col2 VARCHAR(255),col3 VARCHAR(255),col4 VARCHAR(255),id INT(25) NOT NULL AUTO_INCREMENT, KEY (id));
LOAD DATA INFILE '$RootPath/$Today.com' INTO TABLE com$Today FIELDS TERMINATED BY ' ' LINES TERMINATED BY '\n';
delete from com$Today limit 35;
delete from com$Today order by id desc limit 2;
select count(distinct(SUBSTRING_INDEX(domain, '.',-1))) from com$Today INTO OUTFILE '$RootPath/$Today.count';
select count(distinct(SUBSTRING_INDEX(a.domain, '.',-1))) from com$Today a, com$Lfriday b where a.domain=b.domain INTO OUTFILE '$RootPath/$Today.overall';
EOFMYSQL

### Calculation Part
a=$(< $RootPath/$today.count)
b=$(< $RootPath/$Lfriday.count)
c=$(< $RootPath/$Today.overall)


echo "$current_date Today Count For COM TlD $a" >> $LOG
echo "$current_date New Registration Domain Counts $((c - a))" >> $LOG
gdk-pixbuecho "$current_date Deleted Domain Counts $((c - b))" >> $LOG cat $LOG | mail -s "BIZ Tld Count log" 07anis@gmail.comf >= 0.8.0

This is the exact code... This code is not new for you..in my previous post i post the same code, but in that slight changes instead of AWK i am trying MYSQL it works well and reduced my problem,

but my curious is if any error happened in mysql queries how to make that error as log, need your guidance to solve this thread

Thanks alot Guys
Anish kumar.V
# 10  
Old 10-06-2011
Hmmm. I suspect if errors happen, it prints an error message to stderr.

Above all the queries, you could do
Code:
exec 2>errlog

and all errors will be logged to that file. Unfortunately that doesn't tell you exactly which one had the error, or even if.

I don't understand why the || echo bits aren't being run. For some reason mysql must not be returning error when it fails to execute a statement. Maybe it's because of the here-document, try || ( echo "query failed" >> $LOG )
# 11  
Old 10-06-2011
Code:
exec 2>errlog

How to include in this script,

because this also not working
Code:
|| ( echo "query failed" >> $LOG )

and i have another i doubt ,

suppose if one query not execute properly or throw error means how to stop the further process.

Code:
CREATE TABLE com$Today(domain VARCHA(255),col2 VARCHAR(255),col3 VARCHAR(255),col4 VARCHAR(255),id INT(25) NOT NULL AUTO_INCREMENT, KEY (id));

in this query i made a mistake instead of VARCHAR i used VARCHA

it show error but after this error its continously moving to next query.

i dont want like this once the error happened in any of the query then the next process is quit the script and triggered mail to admin the process stopped like that.

Is it possible ??

Thanks Corona688 as a senior your doing such a helpful to me and most of the beginners , and you are very down to earth character thanks a lot for your patience to read my bad english and understand my queries. :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to develop a bash script to create customized report from the server log

Hi, I need to develop a bash script to create customized report from the server log (red hat 5.8 64 bit Operating system). The following is one of the log for our internal application task. <2015.03.03 20:09:52 274 +0800><I><DSCTH01><http-0.0.0.0-443-2><security> GUI request succeeded for... (1 Reply)
Discussion started by: pugazhendhi_r
1 Replies

2. Shell Programming and Scripting

Create, validate and using dynamic variables in Bash scripting

Hi All, I am really struggling to solve this problem, this might be small but I am not able to, can somebody help me? I have few directories and these directories receives text files in large amount with in fraction of seconds. So I just want to send all the files in current directory to... (2 Replies)
Discussion started by: VasuKukkapalli
2 Replies

3. AIX

Script to validate between two environments

Hi, I trust that you are well - I'm a bit new into AIX and I've been assigned a task to write a script that will always validate between our two Prod (Prod A and Prod B) environments to confirm which prod we live at. The two environments are exact replicas and this check I need to put in... (5 Replies)
Discussion started by: Twaggzk
5 Replies

4. Shell Programming and Scripting

Create archive and nil the content of log file using script

Plese help I need a urgent requirement. Ex: test.log requirement : using shell script I need to archive the log file and nil and the content of (test.log) file to 0 kb and then in the archive folder log files are name to test.tar test1.tar test2.tar EX: /home/abc/ test.log ... (1 Reply)
Discussion started by: johney1981
1 Replies

5. Shell Programming and Scripting

Please help me validate script

Hi Guys, Im a newbie to scripting and have a small assignment. can someone please confirm if the script i have written would work fine as we dont have a test server to test :( Scenario - copy 2 files from an ftp server (windows) to a linux machine (a perticular folder). run 2 different... (0 Replies)
Discussion started by: nishantvshah
0 Replies

6. Shell Programming and Scripting

Script creation(How to validate SID?)

I was going write a script from following site. Unix Shell Script to Execute Oracle SQL Query (link removed) My configuration setting for oracle XE. export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server export PATH=$PATH:$ORACLE_HOME/bin export ORACLE_SID=XE but after... (4 Replies)
Discussion started by: pinga123
4 Replies

7. Homework & Coursework Questions

shell script that can create, monitor the log files and report the issues for matching pattern

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write an automated shell program(s) that can create, monitor the log files and report the issues for matching... (0 Replies)
Discussion started by: itian2010
0 Replies

8. Shell Programming and Scripting

Help to create a script to parse log files

Hello everybody, I need some help here to create a script to parse a log file. Here is a sample of the log file : 0x42258940 (Debug) Cache SUMMARY attrs now/668 min/668 max/668. 0x42258940 (Debug) RSVD SUMMARY reserved space max requested/128 MB accounted now/0 MB 0x42258940 (Debug)... (12 Replies)
Discussion started by: Samb95
12 Replies

9. Shell Programming and Scripting

How to create a log file of a script?

hi, How to create a log file of a script. Like spool does . I want to create a log file of whatever the script is doing step wise. like -xvf does or something better then that. thanks ... (3 Replies)
Discussion started by: madfox
3 Replies

10. Shell Programming and Scripting

permissions to create log file from script

hi all, have a script which i am using to generate a log file. i use "touch out.log" command to create the file and later on i want to echo lines to this file. for some reason it keeps giving me this error when i try and create the file ; touch: out.log cannot create i have... (3 Replies)
Discussion started by: cesarNZ
3 Replies
Login or Register to Ask a Question