if statement not working as desired


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers if statement not working as desired
# 1  
Old 02-19-2010
if statement not working as desired

Hello all,

I am trying to write a post-commit hook script using bash script. What I am trying to do here is:

Developers check in their files to a branch. I check the repository and based on the commit I email QA people.

QA verifies and moves the files to a prod branch and email is sent out to managers.

below is an example of sending email to a QA user.
Code:
dev_found=`/usr/bin/svnlook changed $REPOS -r $REV | grep "dev"`

echo '##'$dev_found'##' >> $ACTION_LOG

if[ "$dev_found" <> '' ] then
        for i in `ls $EMAILS`; do
                $SENDMAIL -t < $i
        done
fi

but the problem here is this condition is good for all cases even when dev_found is empty and the conditional check does not work for that.

I have also tried the following conditional checks.
Code:
1. if[ "$dev_found" != '' ] then
2. if[ -n "$dev_found" ] then
3. if[ "$dev_found" != "" ] then
4. if[ "$dev_found" <> "" ] then

nothing seem to work. i get email when I move the files from dev branch to other branches like qa or prod. can any one help me with this? Thanks.

KM

Last edited by Scott; 02-19-2010 at 03:46 PM.. Reason: Please use code tags
# 2  
Old 02-19-2010
Hi.

This one (or #1) would be correct:

Code:
3. if[ "$dev_found" != "" ] then

But should look like this:
Code:
3. if [ "$dev_found" != "" ]; then

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read statement not working

hello guys, i am having the below piece of code error () { echo"Press y /n" read ans case $ans in y) main;; n) exit esac } In the abve code, read statement is not working i.e not waiting for user to enter input. ,i tested exit status its 1. could anyone help me to do this ... (11 Replies)
Discussion started by: mohanalakshmi
11 Replies

2. Shell Programming and Scripting

Cron job is not working in the desired manner on IBM AIX

Hi, I have created a cron job on IBM AIX but it is not working in desired manner ! Here are the steps which I have followed :- #!/bin/ksh #------------------------------------------------------------------ find /some/file/at/the/user/side/test.log -exec cp {}... (8 Replies)
Discussion started by: acidburn_007
8 Replies

3. Shell Programming and Scripting

Cshell if statement not working

Hi .I am trying to check the first arguments =-s and the third =-d,but it doesnt work ,any idea why It gives me if: Missing file name Thanks #case -s and files if( $1 == "-s" && $3 != "-d" ) then echo "case s" endif (1 Reply)
Discussion started by: lio123
1 Replies

4. Shell Programming and Scripting

If statement is not working.

Hi. With the help of this group I have created a shell script to find the factorial of a number. OK. Then I got wild.;) I tried to put in a check to make sure the entry is a number. read num If )) then echo "This is not a valid number. Try again." fi while (( $var <= $num)) more... (5 Replies)
Discussion started by: Ccccc
5 Replies

5. UNIX for Dummies Questions & Answers

until statement not working

im trying to write an until statement which dont go onto the next stage until the user inputs a certain phrase. It is then stored in an array. Ive come up with this code so far but its not working and i dont know why. read in1 until do echo "Incorrect, try again" ... (2 Replies)
Discussion started by: strasner
2 Replies

6. Shell Programming and Scripting

C shell integer tests, less than and more than, not working as desired

Hello, I am creating a script that gives me system load info when i start a shell or log in via ssh(in the /etc/profile.d/ folder). I created it successfully for bash and want it to work with c-shell as well. This is where i'm having problems, the integer test in the if sentence does not work... (3 Replies)
Discussion started by: str1fe
3 Replies

7. UNIX for Dummies Questions & Answers

chmod not working as desired

my file had permission -rw-rw-r-- I did chmod +rwx, expecting everything to now be rwx, but it is -rwxrwxr-x why doesn't o have x permission? thanks. (2 Replies)
Discussion started by: JamesByars
2 Replies

8. Shell Programming and Scripting

If statement not working

I understand this question probably poses some child like stupidity, but I can't get this if statement to work for love or money. #!/bin/ksh echo "Input either 1 or 2" read Num if ; then echo "Message 1" if ; then echo "Message 2" else echo "false" fi $ ksh decisions Input either 1... (6 Replies)
Discussion started by: Hazmeister
6 Replies

9. Shell Programming and Scripting

Script not working as desired

Reborg, Sorry to bother you. I have tried the code you suggested and it's not creating new files after they satisfy the criteria. If any of the files don't satisfy the criteria it should not create the files at all. Please see my output below. (39 Replies)
Discussion started by: mhssatya
39 Replies

10. Shell Programming and Scripting

find/if statement not working

Hi guys: I am trying to delete multiple files in a folder with different names. Below is the script that I was trying, but it doesn't work ************************** #!/bin/ksh DATE=`date '+20%y%m%d'` DEL_DIR=<dir where files have to be deleted> let DATE2=$(($DATE - 2)) let DATE1=$(($DATE... (12 Replies)
Discussion started by: geomonap
12 Replies
Login or Register to Ask a Question