Sponsored Content
Top Forums Shell Programming and Scripting Need a clue to write a IF statement Post 302676147 by Soma Das on Tuesday 24th of July 2012 06:38:10 AM
Old 07-24-2012
Java Need a clue to write a IF statement

Hi all, i am writing a shell script in which i got stuck when tried to use a if statement.

This is my code :
Code:
#!/bin/sh
today=`date +"%a %b %e"`
find /prod/logs -name '*.log' -mtime 0 -exec cp {} /home/hzjnr0/test \;
find /home/hzjnr0/test -type f -exec grep -i "successfully" {} \; > /home/hzjnr0/success.txt
#mailx -s "Control-M job success status" abc@xyz.com < /home/hzjnr0/success.txt
grep -i "successfully" success.txt|wc -l
if
[  -lt 29 ]
then
cd /home/hzjnr0/test
for file in *.log
do
grep -iq 'successfully' $file
[ $? -ne 0 ] && echo "$file -> didnot ended successfully for $today" > test.txt
done
#mailx -s "Control-M job failure status" abc@xyz.com < /home/hzjnr0/test/test.txt
fi


The
grep -i "successfully" success.txt|wc -l will give me a value which i need to compare with 29 in the IF staement condition.

IF the condition is false then it will go to the next loop.

Can anybody help me out here.

Last edited by Franklin52; 07-24-2012 at 08:46 AM.. Reason: Please use code tags for data and code samples, thank you
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to write an OR statement

Hi all, I want to check if the first or the second or the third argument of call to a shell script is empty. How do i do that in a short way. I watched some examples and i believe if checks if an argument is NULL. If so, how can i add the checks for argument 2 and 3 in the statement? ... (1 Reply)
Discussion started by: aukequist
1 Replies

2. Shell Programming and Scripting

write statement into one file

I have one file name start.sh in rinku directory. I want to move it to rinku1 directory. I also mantain log file. In the log file I want to write the the statement whenever the move is failed. Example: >echo `mv /rinku/me.tx ../rinku1` | tee -a log1 mv: me.tx: cannot access: No such file or... (5 Replies)
Discussion started by: rinku
5 Replies

3. Shell Programming and Scripting

If statement - How to write a null statement

In my ksh script, if the conditions of a if statement are true, then do nothing; otherwise, execute some commands. How do I write the "do nothing" statement in the following example? Example: if (( "$x"="1" && "$y"="a" && "$z"="happy" )) then do nothing else command command fi... (3 Replies)
Discussion started by: april
3 Replies

4. Solaris

Filesystem filling up and no clue as to why!

df shows that the filesystem is filling up and the usage is 94%. However when I actually traverse to the directory I du shows only about 10% of the space occupied! Below is the output of df and du: >>>df -kh /cbmdata/00 470M 393M 29M 94% /cbmdata/00 >>>/cbmdata/00>... (3 Replies)
Discussion started by: zombiezparadize
3 Replies

5. Shell Programming and Scripting

Awk/sed problem to write Db insertion statement

Hi There, I am trying to load data from a csv file into a DB during our DB migration phase. I am successfully able export all data into a .csv file but those have to rewritten in terms insert statement which will allow for further population of same data in different DB My exiting csv record... (6 Replies)
Discussion started by: bhaskar_m
6 Replies
APD_BREAKPOINT(3)							 1							 APD_BREAKPOINT(3)

apd_breakpoint - Stops the interpreter and waits on a CR from the socket

SYNOPSIS
bool apd_breakpoint (int $debug_level) DESCRIPTION
This can be used to stop the running of your script, and await responses on the connected socket. To step the program, just send enter (a blank line), or enter a php command to be executed. PARAMETERS
o $ debug_level -An integer which is formed by adding together the XXX_TRACE constants.It is not recommended to use MEMORY_TRACE. It is very slow and does not appear to be accurate. ASSIGNMENT_TRACE is not implemented yet.To turn on all functional traces (TIM- ING, FUNCTIONS, ARGS SUMMARY (like strace -c)) use the value 99 RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Typical session using tcplisten bash#tcplisten localhost 7777 APD - Advanced PHP Debugger Trace File --------------------------------------------------------------------------- Process Pid (6118) Trace Begun at Sun Mar 10 23:13:12 2002 --------------------------------------------------------------------------- ( 0.000000): apd_set_session_trace called at /home/alan/Projects/project2/test. php:5 ( 0.074824): apd_set_session_trace_socket() at /home/alan/Projects/project2/tes t.php:5 returned. Elapsed (0.074824) ( 0.074918): apd_breakpoint() /home/alan/Projects/project2/test.php:7 ++ argv[0] $(??) = 9 apd_breakpoint() at /home/alan/Projects/project2/test.php:7 returned. Elapsed ( -2089521468.1073275368) > statement: /home/alan/Projects/project2/test.php:8 > statement: /home/alan/Projects/project2/test.php:8 > statement: /home/alan/Projects/project2/test.php:10 >apd_echo($i); EXEC: apd_echo($i); 0 >apd_echo(serialize(apd_get_active_symbols())); EXEC: apd_echo(serialize(apd_get_active_symbols())); a:47:{i:0;s:4:"PWD";i:1;s:10:"COLORFGBG";i:2;s:11:"XAUTHORITY";i:3;s:14:" COLORTERM_BCE";i:4;s:9:"WINDOWID";i:5;s:14:"ETERM_VERSION";i:6;s:16:"SE SSION_MANAGER";i:7;s:4:"PS1";i:8;s:11:"GDMSESSION";i:9;s:5:"USER";i:10;s:5:" MAIL";i:11;s:7:"OLDPWD";i:12;s:5:"LANG";i:13;s:10:"COLORTERM";i:14;s:8:"DISP LAY";i:15;s:8:"LOGNAME";i:16;s:6:" >apd_echo(system('ls /home/mydir')); >apd_continue(0); PHP Documentation Group APD_BREAKPOINT(3)
All times are GMT -4. The time now is 06:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy