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
DP(8)                                                                [nmh-1.5]                                                               DP(8)

NAME
dp - parse dates 822-style SYNOPSIS
/usr/lib/mh/dp [-form formatfile] [-format string] [-width columns] [-version] [-help] dates ... DESCRIPTION
Dp is a program that parses dates according to the ARPA Internet standard. It also understands many non-standard formats, such as those produced by TOPS-20 sites and some UNIX sites using ctime(3). It is useful for seeing how nmh will interpret a date. The dp program treats each argument as a single date, and prints the date out in the official 822-format. Hence, it is usually best to enclose each argument in quotes for the shell. To override the output format used by dp, the -format string or -format file switches are used. This permits individual fields of the address to be extracted with ease. The string is simply a format string and the file is simply a format file. See mh-format(5) for the details. Here is the default format string used by dp: %<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%> which says that if an error was detected, print the error, a `:', and the date in error. Otherwise, output the 822-proper format of the date. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
None SEE ALSO
ap(8), Standard for the Format of ARPA Internet Text Messages (RFC-822) DEFAULTS
`-format' default as described above `-width' default to the width of the terminal CONTEXT
None BUGS
The argument to the -format switch must be interpreted as a single token by the shell that invokes dp. Therefore, one must usually place the argument to this switch inside quotes. MH.6.8 11 June 2012 DP(8)
All times are GMT -4. The time now is 03:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy