Sponsored Content
Full Discussion: Problem with if logic
Top Forums Shell Programming and Scripting Problem with if logic Post 98424 by rjsha1 on Wednesday 8th of February 2006 04:53:56 AM
Old 02-08-2006
Problem with if logic

Hi there,
In my shell program I have two if statements
the first one checks that the date in yyyymm format is equal to a date from the parameter file in yyyymm format, and that the file and sends an appropiate email

The second one checks that the date in yyyymm format is equal to a date from the parameter file in yyyymm format, and that the new file size is greater the the previous file size and sends an appropiate email


The problem I have is that I get BOTH emails sent; below is the code and the values of the variables - can anyone see what I have done wrong
#month is same but file bigger new data so mail

if [ $cursize -ge $prvsize -a $curdate -eq $prvdate ]; then
subject="New Three Hour Calls for `date +%b %Y`"
mail_report $REPORTTXT
fi

#Month and file size are the same warning email no file send

if [ $cursize -eq $prvsize -a $curdate -eq $prvdate ]; then
echo "In same data email clause"
subject="No New Three Hour Calls for `date +%b%Y`"
mail_report $REPORTTXT

Current month date is 200602 - curdate
Previous Size is 417 - prvsize
Current Size is 417 - cursize
PRevious month date is 200602 - prvdate


An ideas as to what I'm doing wrong
 

3 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help me to figure out the logic for this problem

Hello, i am on 2.6.13-1.1526_FC4smp i have directory named /home , and in there i have directory 2009_10_10 and two files : 2009_10_10.log and 2009_10_11.log How to write shell script which will delete only file/s that don't have his/their 'parent' directory, so in this case , only... (7 Replies)
Discussion started by: tonijel
7 Replies

2. UNIX for Dummies Questions & Answers

if then else logic with while loop problem

Hi Friends, I have to do write a shell file based on one flag.If that flag value is 'N' then process look in $DATA are and the normal process continue.If vaule is 'P' then it check for the files in different location $CONV and move those file in $DATA area and rest of the process... (2 Replies)
Discussion started by: Param0073
2 Replies

3. Shell Programming and Scripting

Nawk if logic problem

nawk '{ fmt="%3s %22s %48s %35s %21s\n"; if ($3==$6 && $1=="STOPLOSS") { tpy="Successful Match"; jnme=$1; sts="File will be loaded"; cntrl=$3; audit=$6; printf (fmt, tpy,jnme,sts,cntrl,audit) >> "'${AUDIT_DATA_FILE}/${AUDIT36}'" }else if ($3!=$6 && $1=="STOPLOSS") { tpy="Mis-Match ";... (4 Replies)
Discussion started by: wawa
4 Replies
DATETIME.SETDATE(3)							 1						       DATETIME.SETDATE(3)

DateTime::setDate - Sets the date

       Object oriented style

SYNOPSIS
public DateTime DateTime::setDate (int $year, int $month, int $day) DESCRIPTION
Procedural style DateTime date_date_set (DateTime $object, int $year, int $month, int $day) Resets the current date of the DateTime object to a different date. PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3). The function modifies this object. o $year - Year of the date. o $month - Month of the date. o $day - Day of the date. RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | Changed the return value on success from NULL to | | | DateTime. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 DateTime.setDate(3) example Object oriented style <?php $date = new DateTime(); $date->setDate(2001, 2, 3); echo $date->format('Y-m-d'); ?> Procedural style <?php $date = date_create(); date_date_set($date, 2001, 2, 3); echo date_format($date, 'Y-m-d'); ?> The above examples will output: 2001-02-03 Example #2 Values exceeding ranges are added to their parent values <?php $date = new DateTime(); $date->setDate(2001, 2, 28); echo $date->format('Y-m-d') . " "; $date->setDate(2001, 2, 29); echo $date->format('Y-m-d') . " "; $date->setDate(2001, 14, 3); echo $date->format('Y-m-d') . " "; ?> The above example will output: 2001-02-28 2001-03-01 2002-02-03 SEE ALSO
DateTime.setISODate(3), DateTime.setTime(3). PHP Documentation Group DATETIME.SETDATE(3)
All times are GMT -4. The time now is 11:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy