Sponsored Content
Top Forums Shell Programming and Scripting How to Create LOG and Validate for this Script Post 302562274 by anishkumarv on Thursday 6th of October 2011 11:39:04 AM
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 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
DATE_DEFAULT_TIMEZONE_SET(3)						 1					      DATE_DEFAULT_TIMEZONE_SET(3)

date_default_timezone_set - Sets the default timezone used by all date/time functions in a script

SYNOPSIS
bool date_default_timezone_set (string $timezone_identifier) DESCRIPTION
date_default_timezone_set(3) sets the default timezone used by all date/time functions. Note Since PHP 5.1.0 (when the date/time functions were rewritten), every call to a date/time function will generate a E_NOTICE if the timezone isn't valid, and/or a E_WARNING message if using the system settings or the $TZ environment variable. Instead of using this function to set the default timezone in your script, you can also use the INI setting date.timezone to set the default timezone. PARAMETERS
o $timezone_identifier - The timezone identifier, like UTC or Europe/Lisbon. The list of valid identifiers is available in the "List of Supported Time- zones". RETURN VALUES
This function returns FALSE if the $timezone_identifier isn't valid, or TRUE otherwise. EXAMPLES
Example #1 Getting the default timezone <?php date_default_timezone_set('America/Los_Angeles'); $script_tz = date_default_timezone_get(); if (strcmp($script_tz, ini_get('date.timezone'))){ echo 'Script timezone differs from ini-set timezone.'; } else { echo 'Script timezone and ini-set timezone match.'; } ?> CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | Now throws E_WARNING rather than E_STRICT. | | | | | 5.1.2 | | | | | | | The function started to validate the $time- | | | zone_identifier parameter. | | | | +--------+---------------------------------------------------+ SEE ALSO
date_default_timezone_get(3), "List of Supported Timezones". PHP Documentation Group DATE_DEFAULT_TIMEZONE_SET(3)
All times are GMT -4. The time now is 02:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy