Sponsored Content
Top Forums Shell Programming and Scripting Multipe conditions in if statement Post 302348545 by Just Ice on Friday 28th of August 2009 02:36:39 PM
Old 08-28-2009
another way ...

by default, the email will be sent every 2 hours starting 0628 and ending 1828 unless the start and end times are changed ... need to set 3 arguments if needing to extend the end hour and 4 arguments if needing to change the minute with Y as the first argument ... $1 should be Y to send, N to not send, G to send immediately ... if G is selected, no other arguments are required ...


Code:
#! /bin/ksh
SEND=$1
SEND=${SEND:=Y}
START=$2
START=${START:=6}
END=$3
END=${END:=18}
MIN=$4
MIN=${END:=28}
MYHR=$(date +%H)
MYMIN=$(date +%M)

if [ $MYHR -ge $START -a $MYHR -le $END -a $MYMIN -eq $MIN ]
then
      ZERO=$(expr $MYHR % 2)
      if [ $ZERO = 0 ]
      then
            OK=Y
      else
            OK=N
      fi
fi

case $SEND in
Y) if [ $OK = "Y" ]
    then
          mail_report
    fi ;;
G) mail_report ;;
esac


this could be better but i don't have a sun box nor the time to test ... test properly before putting anything into production mode ...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

if statement with two conditions

Hi, I am trying to use && set up to match two conditions within ksh: if && then '''Do something if somehow, I keep getting error message telling me that ] is missing. What's wrong with my code? Thanks a lot for your help! (1 Reply)
Discussion started by: cin2000
1 Replies

2. Shell Programming and Scripting

How to giv two conditions in IF statement..??

Actually i need to satisfy both the condition.. lik i'm lookin for two different files.. and if BOTH the files r not present then it should run the followin script.. For example inputfile1=data/in/inputfile1.txt inputfile2=data/in/inputfile2.txt if then echo " " echo... (6 Replies)
Discussion started by: RRVARMA
6 Replies

3. UNIX for Dummies Questions & Answers

Two conditions in one if statement

I'm totally new with bash programming and I don't get it how to put two conditions in one if statement. My code looks like this: h=`date +%k` if && ]; then$h is 10 but I don't get into my if statement. What's wrong here? (5 Replies)
Discussion started by: borobudur
5 Replies

4. Shell Programming and Scripting

If statement with multiple conditions

I have a script that runs on multiple servers. What I want to do is have the script do the following: if $(hostname) is equal to server or server2 then TO_DIR=go else TO_DIR=stop fi I have tried: if if ] Server is hpux. any ideas? (1 Reply)
Discussion started by: cpolikowsky
1 Replies

5. Shell Programming and Scripting

Multiple conditions in a CASE statement

is it possible to use multiple conditions in a CASE statement? And if so, what is the syntax? I'm trying to use one but can't seem to get it right. I want the statement to be CASE $vendor OR $alias condition 1) statements; condition 2) statements; etc. esac but I keep... (25 Replies)
Discussion started by: Straitsfan
25 Replies

6. Shell Programming and Scripting

Multiple Conditions Perl if Statement

Hello, I'm trying to put together a script that involves pulling data from a config file. I'm attempting to write an if statement to validate one of the pieces of data from the config file, but I think I'm fat fingering it somehow. $config{VALUE} is being pulled from a config file but can only... (4 Replies)
Discussion started by: Picch
4 Replies

7. Shell Programming and Scripting

How to Evaluate two conditions in single if statement

I am trying to test two conditions in a single if and getting syntax error on -a and && if ] ; then echo "variable a equals to variable b" else echo "variable a not equal to variable b" fi in second attempt I used -a instead of &&, referring to other website, but not sure that... (1 Reply)
Discussion started by: praxis1
1 Replies

8. Shell Programming and Scripting

Multiple conditions inside my if statement

Hello, I am using shell scripting and I am recieving odd results from my if statement if I want it to enter the loop only if L1 is equal to zero and one of the other criteria are filled, however it is entering at other times as well. What can i do to fix this? i tried seperating it... (6 Replies)
Discussion started by: ryddner
6 Replies

9. UNIX for Dummies Questions & Answers

If statement with two boolean conditions

#!/bin/bash if && then echo "True" else echo "False" fi Hi everyone, I am new to UNIX, here I have a if statement elevating two boolean conditions. I thought the output should be True because there are + in the statement. But it turns out to be False. Can anyone... (3 Replies)
Discussion started by: mryuyu1111
3 Replies

10. Shell Programming and Scripting

How to Check Multiple conditions in IF statement?

I wish to check two conditions inside the if statement Condition 1: The two file contents should be identical // using cmp command for this. Condition 2: The two filenames should NOT be the same. This is what i did in vain. if ]; then where entry1 and entry2 are ls *.txt | while... (7 Replies)
Discussion started by: mohtashims
7 Replies
Timer(3pm)						User Contributed Perl Documentation						Timer(3pm)

NAME
Template::Timer - Rudimentary profiling for Template Toolkit VERSION
Version 1.00 SYNOPSIS
Template::Timer provides inline timings of the template processing througout your code. It's an overridden version of Template::Context that wraps the "process()" and "include()" methods. Using Template::Timer is simple. use Template::Timer; my %config = ( # Whatever your config is INCLUDE_PATH => '/my/template/path', COMPILE_EXT => '.ttc', COMPILE_DIR => '/tmp/tt', ); if ( $development_mode ) { $config{ CONTEXT } = Template::Timer->new( %config ); } my $template = Template->new( \%config ); Now when you process templates, HTML comments will get embedded in your output, which you can easily grep for. The nesting level is also shown. <!-- TIMER START: L1 process mainmenu/mainmenu.ttml --> <!-- TIMER START: L2 include mainmenu/cssindex.tt --> <!-- TIMER START: L3 process mainmenu/cssindex.tt --> <!-- TIMER END: L3 process mainmenu/cssindex.tt (17.279 ms) --> <!-- TIMER END: L2 include mainmenu/cssindex.tt (17.401 ms) --> .... <!-- TIMER END: L3 process mainmenu/footer.tt (3.016 ms) --> <!-- TIMER END: L2 include mainmenu/footer.tt (3.104 ms) --> <!-- TIMER END: L1 process mainmenu/mainmenu.ttml (400.409 ms) --> Note that since INCLUDE is a wrapper around PROCESS, calls to INCLUDEs will be doubled up, and slightly longer than the PROCESS call. AUTHOR
Andy Lester, "<andy at petdance.com>" BUGS
Please report any bugs or feature requests to "bug-template-timer at rt.cpan.org", or through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. ACKNOWLEDGEMENTS
Thanks to Randal Schwartz, Bill Moseley, and to Gavin Estey for the original code. COPYRIGHT &; LICENSE This library is free software; you can redistribute it and/or modify it under the terms of either the GNU Public License v3, or the Artistic License 2.0. * http://www.gnu.org/copyleft/gpl.html * http://www.opensource.org/licenses/artistic-license-2.0.php perl v5.12.4 2009-03-07 Timer(3pm)
All times are GMT -4. The time now is 08:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy