If condition and htm not working


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users If condition and htm not working
# 1  
Old 04-07-2010
If condition and htm not working

Code:
checkSync()
{
        CONNECT_STRING=TLDB61/TLDB61@TL10G
        SQLPLUS_SETTINGS="SET PAGESIZE 0 LINESIZE 1500 ECHO OFF TRIMS ON TAB OFF FEEDBACK OFF HEADING OFF"
        SQL_RESULT_SYNC_PMCM=`sqlplus -s ${CONNECT_STRING} << EOF
        ${SQLPLUS_SETTINGS}
        (SELECT CYCLE_CODE,CYCLE_MONTH,CYCLE_START_DATE, CYCLE_CLOSE_DATE FROM PM1_CYCLE_STATE MINUS SELECT CYCLE_CODE,CYCLE_I
NSTANCE,CYCLE_START_DATE, CYCLE_END_DATE FROM CM1_CYCLE_INSTANCE) UNION (SELECT  CYCLE_CODE,CYCLE_INSTANCE,CYCLE_START_DATE, C
YCLE_END_DATE FROM CM1_CYCLE_INSTANCE MINUS SELECT CYCLE_CODE,CYCLE_MONTH,CYCLE_START_DATE, CYCLE_CLOSE_DATE FROM PM1_CYCLE_ST
ATE);
        exit;
        EOF`

         if [$SQL_RESULT_SYNC_PMCM != 0]        then
                 echo "$SQL_RESULT_SYNC_PMCM" | mailx -s "FAILURE - Check the pm1_cycle_state and cm1_cycle_instance not in sy
nc" abc.ef@xyz.com


        fi

        echo "$SQL_RESULT_SYNC_PMCM" | awk ' \
BEGIN{
print ""
print "<html><body><table cellpadding=2 cellspacing=0 style=\047border-style: ridge; font-family: Verdana, Arial, Helvetica, s
ans-serif; font-size: 12px; font-weight:bold\047>"
print "<tr style=\047color: white; background-color:6DA2D7\047><td>CYCLE_CODE</td><td>CYCLE_MONTH</td><td>CYCLE_START_DATE</td
><td>CYCLE_CLOSE_DATE</td></tr>"
}
{print "<tr bgcolor=CCCCCC><td>" $1 "</td><td>" $2 "</td><td>" $3 "</td><td>" $4 "</td> "</td></tr>" }
END {
print "</table></body></html>"
}' > ALERT.htm

}


In the above code I am trying to collect a result from a query to (SQL_RESULT_SYNC_PMCM)

Then checking if the content is not zero (how to check it ) my condition is not working.

Also trying to collect it in a htm which is also not working

Please help correct the code.

Last edited by pludi; 04-07-2010 at 05:10 AM.. Reason: code tags, please...
# 2  
Old 04-07-2010
Instead of
Code:
if [$SQL_RESULT_SYNC_PMCM != 0]        then

try
Code:
if [ "${SQL_RESET_SYNC_PMCM}" -ne 0 ] ; then

# 3  
Old 04-07-2010
Quote:
EOF`
This line should start in column 1 and must not be indented.

Code:
EOF`


With the "EOF" line misplaced everything from that line onwards was being given to sqlplus not shell.
This is why you didn't get a syntax error for the faulty "if" statements.

Last edited by methyl; 04-07-2010 at 01:55 PM.. Reason: more
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If condition on shell not working , not sure what is the mistake I am doing?

I have a requirement to perform specific set of tasks based on server , So I want to have the condition(s) defined based on server. Here is the script I came up with and I have read multiple blogs and couldn`t find any mistake from my script. Can you guide on what I am overlooking here ? ... (2 Replies)
Discussion started by: Varja
2 Replies

2. UNIX for Beginners Questions & Answers

If condition is not working and getting error

Hi Team, If condition is not working properly and getting below error # ./score1.sh Enter your score ('q' for quit): 102 Enter your score ('q' for quit): q ./score1.sh: line 9: q: integer expression expected Average is: 102%. Exit. Actual code # Calculate the average of given... (3 Replies)
Discussion started by: Torrid
3 Replies

3. Shell Programming and Scripting

Search replace hostname in htm files

Need assistance in changing the hostname I have multiple html files in a directory , its src is pointing to houston.sp.com and it needs to change to alaska.sp.com . Below is the example Trying to use perl to change it . Need suggestiong <img border="0"... (3 Replies)
Discussion started by: ajayram_arya
3 Replies

4. Shell Programming and Scripting

finding php, html, htm files

how can i limit the output to only php, html, htm files? i found this as one way find . -regex ".*\(php\|html\|htm\)$" -type f -print0 | xargs -0 grep 'keyword'and it works but is a bit slow is there any faster way? i tried something like this but it doesnt work: find ./ -iname "*.php"... (2 Replies)
Discussion started by: vanessafan99
2 Replies

5. Shell Programming and Scripting

Using ssh to transfer file not working inside if-condition

Hi all, ssh uname@remote_server 'cat /tmp/remote_file_name > home_dir/a512386/new/local_file_name' The above given command is working fine. but if i try to move the file only if exists in the remote server i.e) giving the same within if condition it executes but the file is not stored in my... (1 Reply)
Discussion started by: Shri123
1 Replies

6. Shell Programming and Scripting

wild card in if condition not working

Hi, I am using RHEL5. I have following if condition. if In the above condition, if the value of a contains word WARNING, it should match. i.e., WARNING_MESSAGE, CRITICAL WARNING, WARNING ALERT etc. it should match. For b, alert error, ALERT ERROR, ERROR IMMEDIATE ACTION REQUIRED, etc... (2 Replies)
Discussion started by: user7509
2 Replies

7. Shell Programming and Scripting

If condition not working

Hi Gurus, I have shell script in which i have to check if time is between to possible value or not. For that i am using following line of code if then echo 'Found In Between' echo $ftime ... (5 Replies)
Discussion started by: MANISH KU
5 Replies
Login or Register to Ask a Question